View Full Version : Oh Nescape gods, what sin have I comitted now?
gorilla1
09-05-2002, 05:29 AM
The piece of code below works fine in IE, and works fine in NS4 when loaded from my own hard drive, but when loaded from a web page, it crashes the NS4 browser. Can anyone see why NS4 would object in this way?
G
<noscript>
<td width="100%" valign="top" style="background-image:url('bgch18.gif'); background-repeat: no-repeat; background-position: top center" bgcolor="#ffffff">
</noscript>
<SCRIPT type='text/javascript' LANGUAGE="JavaScript1.2">
<!--
if (screen.width > 800) {
var wrtStr = '<td width="100%" valign="top" style="background-image:url(\'bgch8.gif\'); background-repeat: no-repeat; background-position: top center" bgcolor="#ffffff">';
document.write(wrtStr);
}
else {
if (screen.width <= 800) {
var wrtStr = '<td width="100%" valign="top" style="background-image:url(\'bgch18.gif\'); background-repeat: no-repeat; background-position: top center" bgcolor="#ffffff"> ';
document.write(wrtStr);
}
}
// -->
</script>
joh6nn
09-05-2002, 05:53 AM
i don't know. nothing jumps out at me, but that doesn't mean anything.
skeatt
09-05-2002, 06:37 AM
As a junior to JS, I'd be guessing but I found this while looking up the resizeTo command.....
Warnings:
There are some security implications for moving windows in Netscape 4. They are meant to stop you hiding a window by shifting it off-screen. Your script will need to be granted the UniversalBrowserWrite privilege to allow it to move the window outside the screen area.
Maybe it thinks your doing something like this?
realisis
09-05-2002, 06:56 AM
Gorilla, well for starters, you could express the script part a bit more succcinctly by stating simply:
<SCRIPT type='text/javascript' LANGUAGE="JavaScript1.2">
<!--
BG = (screen.width > 800)?"bgch8" :"bgch18"
document.write('<td width="100%" valign="top" style="background-image:url(' +BG+ '.gif); background-repeat: no-repeat; background-position: top center" bgcolor="#ffffff">')
//-->
</script>
Try the above. If it doesn't work, here's a couple of other hints off the top of my head:
1)
I'm convinced the above code - on its own - is valid. But maybe it's interacting with something else on your page. Since you're writing an opening TD tag, are you sure that you're closing it also?
2)
If the above doesn't work as is, you might try adding document.close() prior to closing the script (if you're not doing any subsequent doc.writes() on the page). This tells NS4 that the page is ready for layout, and sometimes the browser appears to hang without it.
3)
Netscape 4.x doesn't like locally-defined styles in some elements. Since most of the BG style declarations aren't recognized by NS4 anyway, you could sniff it out, and supply it with this instead:
<SCRIPT type='text/javascript' LANGUAGE="JavaScript1.2">
<!--
BG = (screen.width > 800)?"bgch8" :"bgch18"
BGtype = (document.layers)?"background='" +BG+ "' " :"style='background-image:url(" +BG+ ".gif); background-repeat: no-repeat; background-position: top center' "
document.write('<td width="100%" valign="top" '+ BGtype+ ' bgcolor="#ffffff">')
//-->
</script>
Needless to say, don't copy this out by hand. Rather, copy it exactly by pasting directly from the screen, as the visual distinction here between single and double quotes can lead to confusion.
...
Also, I don't think the single-quotes are necessary within the NOSCRIPT style URL... fwiw, try background-image:url(bgch18.gif)
...
Hope one of these does the trick?
gorilla1
09-05-2002, 01:17 PM
Thanks for all the thoughts... Realisis, I tried each of those excellent suggestions, but same result. Very odd that the code works fine loaded into NS from my disk, but not from the server.. Finally, I simply took out the javascript and used the same background for all screen sizes - and it looked not so bad.
G
realisis
09-09-2002, 05:55 PM
Gorilla: glad to help. Although it irks me that none of the ideas solved the problem. I get a perverse thrill out of making NS4 do things it doesn't want to do.
I was gonna offer to check out your page online, but since you've opted to just go with the one bg size, I guess it's not necessary.
Cheers -
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.