Search for keyword in URL

by akshatha suchethan

HTML

<div id="sidenav">
uygyuhguiybg
</div>
<div id="contentBox">
  <span>Success!</span>
</div>

CSS

#sidenav {
  position: relative;
  background-color: #000;
  width: 190px;
  height: 300px;
}

#contentBox {
  position: relative;
  background-color: red;
  height: 300px;
  margin-left: 220px;
}

JavaScript

// Get URL
  var url = window.location.href;
  // Get DIV
  alert(url);
  var msg = document.getElementById('sidenav');
  // Check if URL contains the keyword
  //alert(url.search( 'jshell' ));
  if( url.search( 'jshell' ) > 0 ) {
      // Display the message
      	msg.style.display = "none";
        document.getElementById('contentBox').style.marginLeft = '0px';
      }
      else
      {
      	msg.style.display = "block";
        document.getElementById('contentBox').style.marginLeft = '220px';
      }