Working with parameters in the URL from javascript

Task is to hide some page elements based on parameter in the URL.

Example URL: http://mypage.com?hidePrintButton=true

In this case we should hide print button.

Implementation (without jQuery):
<script language='JavaScript'>
window.onload = function() {
if(document.URL.indexOf('hidePrintButton=true')!==-1){
document.getElementById('printButton').style.visibility='hidden';
}
}
</script>
<button id="printButton" class="link icon iconPrint notPrintable pagePrint" title="Do print page" type="button"></button>

 

Leave a Reply

Your email address will not be published. Required fields are marked *

5  +  5  =  

Skynin cache:
Array ( [cache mode] => capture [requestKey] => 732fce69c22a0877fe45a8db799508195e.sc [skycache_disable_capture] => false )