Help - Search - Members - Calendar
Full Version: Javascript Enabling/Disabling
Forums > Resource Center > Webmasters' Corner
instantmusic
Forgive me if my net vocabulary is incorrect. I'm using javascript in a header at f*ck Yeah Sports. I use it for smooth image transitions. I have the javascript in my header and javascript images in a div (#headline). I hide this div with (display:none) on every page except the front page. The div disappears on every other page, as expected.

The problem is, the javascript (the images) aren't disabled and they show up on the top left of the browser instead. At first I didn't notice it. It takes a couple of seconds for it to show up and then it appears and disappears.

See the issue for yourself: f*ck Yeah Sports

How do I correct this (hide/disable it)?



Mike
Try adding !important after 'none' and before the semicolon:

CODE
#headline {display:none!important;}

If it still doesn't work, try adding height and width properties then setting them to 0px.
instantmusic
Both didn't work. Isn't there some javascript like this:

CODE
if (condition) {(action)}
else {(action)}


Where my javascript ppls?
fixtatik
You could check the page, and if it's the home page, run the script:
CODE
if(window.location == 'http://f*ckyeahsports.tumblr.com/' || window.location == 'http://f*ckyeahsports.tumblr.com/page/1') {
  run the script
}

You don't really need an "else" statement in this case, since if the page isn't one of those two, it won't do anything with the JavaScript.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.