How can I use window.location.href to hide .banner when the url= someurl.com/hidebannerpage.aspx?
How can I use window.location.href to hide .banner when the url= someurl.com/hidebannerpage.aspx?
Please post a link to the page on your site that contains the problematic code so we can check it out.
If this has to do with ads that are being put on your page as part of some hosting package deal (or something similar) you have, it is against the policy of this forum to help people avoid fulfilling the terms of service of their host.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Here is what I am working with;
Code:<html> <body> <script type="text/javascript"> z=window.location.pathname; document.write(z); // result is /js/tryit_view.asp if(z=="/js/tryit_view.asp") { document.getElementById('banner').style.display = 'none'; } else { } </script> <div id="banner" style="display:block"><h3>This banner is removed if specific pathname appears in url.</h3></div>
Why doesn't this work?
Are you sure you want getElementById? You said you wanted ".banner" which looks like a class to me. Without seeing the page in question it is hard to help.
The script looks fine, except for one thing, and possibly another. The 'deal breaker' is that at the time that it executes, there is no element by the id banner. The other possible problem is the empty else. If there is no else, there shouldn't even be the else statement or its empty braces. I'm not sure if that one would cause an error, but it probably would in some browsers.
Try:
Code:<html> <body> <div id="banner"><h3>This banner is removed if specific pathname appears in url.</h3></div> <script type="text/javascript" defer="defer"> var z=window.location.pathname; document.write(z); // result is /js/tryit_view.asp if(z=="/js/tryit_view.asp") document.getElementById('banner').style.display = 'none'; </script>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks