|
-
Jan 29th, 2002, 06:37 AM
#1
Thread Starter
Fanatic Member
Why won't this simple page work in NS4 ?
I have a site which requires JS to be switched on. I would like the home page to display different content if JS isn't switched on, as below.
However NS4 gets to the document.write bit and stops.
I have tried it with and without the window. prefix and with and without the open() and close() lines all to no avail, can anyone help?
Code:
<HTML>
<HEAD>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<P>Text At Top Of Page</P>
<SCRIPT LANGUAGE=javascript>
<!--
window.document.open()
window.document.writeln("Javascript is on")
window.document.close()
//-->
</SCRIPT>
<NOSCRIPT LANGUAGE=javascript>
Javascript is off
</NOSCRIPT>
<P>Text At Bottom Of Page</P>
</BODY>
</HTML>
-
Jan 29th, 2002, 06:53 AM
#2
PowerPoster
hi
Use this:
Code:
<HTML>
<HEAD>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<P>Text At Top Of Page</P>
<SCRIPT LANGUAGE=javascript>
<!--
window.document.writeln("Javascript is on")
//-->
</SCRIPT>
<NOSCRIPT >
Javascript is off
</NOSCRIPT>
<P>Text At Bottom Of Page</P>
</BODY>
</HTML>
Hope this helps.
-
Jan 29th, 2002, 07:26 AM
#3
Thread Starter
Fanatic Member
Hi,
I am still getting the same problem with your code I am afraid.
The progress bar in the status bar hangs at 39%, the CPU looks like it is getting absolutely hammered as NS runs at 90% +
and the text in the status bar reads 100% of 351!
-
Jan 29th, 2002, 11:56 AM
#4
Thread Starter
Fanatic Member
God I hate Netscape!
Well, after a reboot Netscape finally consented to show the page as I hoped it would (with my original code!).
It then decided that Image1 and Image2 on my page (which have their src changed dynamically in the Window OnLoad Event) had no properties.
(This is despite the fact that it handles the OnLoad event fine when the document.write event isn't used in-line and the content is written as static HTML instead)
I found that after moving the images up above the <SCRIPT> tag netscape suddenly agreed that they did actually have properties and consented to change their srcs.
The presence of the images at the top of the page (which are both 1 pixel transparent gifs) led to an unsightly line of extra space at the top of the page (Despite the height and width both being set to 1).
Whilst I was happy to settle for this in NS4 I wanted to set the display style to none for the purposes of IE.
However just simply adding in style="DISPLAY: none" to the image tag suddenly caused the document.write event to go all screwy.
Whereas before it had written the HTML fine it suddenly failed and instead wrote the raw HTML source across the page!!
I was able to get round this by using:
if (document.all){
Image1.style.display='none'
Image2.style.display='none'
}
in the onload event.
But I don't know how long netscape 4 users expect people to bother trying to work around their crappy browser.
Does anyone have any stats on overall browser market share so I know what proportion of potential users I would be excluding by just targetting IE 4.0 + and NS 6.0+ ?
-
Jan 29th, 2002, 01:03 PM
#5
Frenzied Member
A couple of comments...
You were saying that you had to move the object above the script block to get it to work. Well, the page is processed from top to bottom. You can't access an object that hasn't been written, yet.
Also, as to who you will exclude, I don't know the numbers, but it comes down to this (which is what I do)...
write your page to all of the industry standards. If the browser can't handle it, then it is the user's fault, not yours. We have standards for a reason, and if people don't want to get onboard, then too bad. Now you may say that "Foo Browser is used by 75% of the user base". That's nice, and if Foo Browser doesn't want to conform, I don't care. If they want to put forward their own, open, independently arbitrated, standard, then great. Until that day, c'est dommage.
As to who controls the standards:
W3C controls HTML/CSS/DOM. ECMA controls the script mappings to the the DOM (ECMA-262). Netscape controls JavaScript, which is meant to be ECMA-262 compliant. MS controls JScript and VBScript, which have not been widely accepted in UAs (and are not terribly open standards anyway), so it is best to ignore these.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 29th, 2002, 05:34 PM
#6
IE6 doesn't seem to care but maybe NS wants semi-colons as the end of the script lines?
Code:
<SCRIPT LANGUAGE=javascript>
<!--
window.document.open();
window.document.writeln("Javascript is on");
window.document.close();
//-->
</SCRIPT>
*shrug*
Paul
-
Jan 30th, 2002, 01:26 AM
#7
Hyperactive Member
Hi Martin,
below is a link to the latest browser current stats as compiled by W3schools...
It may answer a few of your questions...
http://www.w3schools.com/browsers/browsers_stats.asp
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Jan 30th, 2002, 05:03 AM
#8
Thread Starter
Fanatic Member
Cheers all,
Sorry, I was having a bad day yesterday!
Software Maker, those stats are pretty useful for my particular bias!
CiberTHuG,
You were saying that you had to move the object above the script block to get it to work. Well, the page is processed from top to bottom. You can't access an object that hasn't been written, yet.
I probably didn't make myself that clear!
The Script block which I had to move the images above was the document.write Script block. The image src changing code was in a separate script block in the window_onload() function in the Head of the page!
I also tried using a window.setTimeOut to make sure that the event didn't fire until the page was definitely fully written but still with no joy. For some reason the position of the images seemed to be the stumbling block!
(The page worked fine in IE4.0+ and NS 6.0)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|