Hello, I am trying to setup a simple "If Else" statement to display a certain div based on a string in the URL.
So if the url is domain.com/source1 display only source1 div
If the url is domain.com/source2 display only source2 div
This is what I have tried to at least show or hide based on one source.. haven't gotten to multiples yet!
Code JavaScript:<script type="text/javascript"> if(document.URL.indexOf("source1") >= 0){ document.getElementById('source1').style.display = "block"; } else document.getElementById('source1').style.display = "none"; } </script>
This is the HTML
Code HTML4Strict:<style type="text/css"> .show {display: block; } </style> <div id="source1" class="show">content for source one div.... </div>
Thank you very much in advance for any help you can provide. I have carefully searched this and many other forums to find an answer.


Reply With Quote


Bookmarks