PDA

View Full Version : style.display = none | BUGGY, but why?



a_design_interactive
02-09-2007, 05:02 AM
hello. as one of many thousands of versions of the javascript ditty which is used to "hide" a < div > for a while, later to be revealed-- as in the case of something like this, you'll see in blogs n stuff where the "click for more" will "open" stuff under the "click for more" which was there all the time, but the CSS display is set to NONE so you can't see it until the script is activated:

this is for visual effect onl

[click here for more . . .]

blah, blah --- and blah!
the above doesn't really have javascript of course, but is for visual effect only to illustrate...
the end.

well, mine i think is "messed up".
i want to know why, if i have javascript disabled, will the browser try to take me to a directory by the SAME name of the ELEMENT ID which i used to create the special effect.

please have a look and try mine (http://clubrive.com/markview/metesties/peekatest.html). the code looks like this:

<script type="text/javascript">
<!--
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "block" ) {
el.style.display = 'block';
} else {
el.style.display = 'none';
}
}
//-->
</script>
<style type="text/css">
<!--
dd#peekaboo {
display: none;
}
-->
</style>
<!-- SNIP -->
<dl id="portlist noscripting">
<dt class="shotone">click the bold
<a onclick="switchMenu('peekaboo');" title="the Amazing Disappearing: Peek-a-Boo!">
<strong style="font-variant:small-caps;">Text We Can View All the Time</strong></a> Like Right Now Ain't it Cool</dt>
<dd class="shotone" id="peekaboo">
<h1>Peek - a - BOOOOOO!</h1></dd></dl>

please view my test page (http://clubrive.com/markview/metesties/peekatest.html)

MY QUESTION:
1.) is this "broken"? if so, what might i try to fix it?

2.) if this is NOT "broken", then what would be the typical "workaround" so if a user doesn't have javascript enabled, he or she at least won't think the web site has broken links. (i'd rather the div never display-- than the div not display AND have this broken link effect)

3.) do you have a better way of doing this? i'm totally open for improvement here as i'm 99.9&#37; sure i didn't write this code from scratch

i know i could get away w/ leaving the code the way it is-- because most people will probably not have any problem-- will never get the "page not found" error, but inevitably, we know they're out there.

thanks for your help!!!

jscheuer1
02-09-2007, 05:14 AM
Not happening here in Opera 9.01, FF 1.5.0.9 or IE 7. In all three browsers it worked fine with javascript enabled. In all three it simply does nothing with javascript disabled.

a_design_interactive
02-10-2007, 04:52 PM
weird. that is sooo weird.

what ELSE could possibly be causing this? i'm pretty sure i get it in all browsers (opera, ie, Firefox, seamonkey), both on XP, AND Linux (FC5).

i find it difficult to believe that i'm the only person who's experienced this oddity. does this not look familiar (or my description "sound" familiar) to ANYone?

[i totally didn't expect anyone to respond as you have, john.]

what about the code-- does the code itself look okay? or problematic? (it looks 'technically' okay to me, but i'm new to javascript, so i can't be certain, obviously)

EDIT:
NO! you're RIGHT! it doesn't do it in opera. -- this leads me to believe maybe it's a Firefox extension-- something i use ALL of the time (such as NoScript, which i also use in Seamonkey)

how do i disable javascript in IE7? i looked-- could NOT find that setting in there-- it must be named something else?

EDIT2: is that "script debugging" thing useful for anything in IE7? i don't get it-- that's not actually "turning off" javascript though is it? it's the only topic that shows when i search for javascript IE help, not to mention-- if i "uncheck" it, opening the settings again shows it's checked again!)

EDIT3:
man-- i give up on this thing for now. i guess it's not that important-- but i would like to know what's going on. i've got bigger fish to fry momentarily. maybe someone else who has this problem will stumble upon this thread and we can hack at it in the future. thanks for your input, john

jscheuer1
02-10-2007, 05:42 PM
To view your page as it would look in IE without javascript is a little tricky. For a local page, just make sure that it doesn't have 'the mark of the web' on it and open the page in a clean instance of the browser. You will get an active x warning, click through to not allow it and your page will be displayed without javascript. For live pages:

Tools > Internet Options > Security (tab) > Custom Level (button)

Scroll down to near the end and under the Scripting heading the first block is Active Scripting, check Disable. Click OK, yes, etc.

To re-enable, do the same but choose Enable.


Oh, and your code looked OK to me as well.