You need to reorder your "document.write" statements since you are
writing your result _before_ the HTML header:
function displayresult()
{
for (var b = 0; b <= index; b++){
var userinput = new String(userans[b]);
var ansval = new String(ans[b]);
if (trim(ansval) == trim(userinput)) { result = result +
10 };
}
alert(result);
document.write('<html><head>');
document.write('<link rel="stylesheet" type="text/css"
href="../Style.css">');
document.write('</head><body bgcolor="#000000" link="#C0C0C0"
vlink="#C0C0C0" text="#FFFF00">');
document.write ("The marks you have scored is: "+ result);
document.write('</form></body>');
}
-----Original Message-----
From: arun [mailto:arun@l...]
Sent: 28 May 2002 06:48
To: JavaScript HowTo
Subject: [javascript_howto] document.write() on Netscape
Hi all,
The below code is a javascript function which works with IE but give
problem in Netscape. The alert message is displayed in both the browser.
The real problem comes when the statement document.write is executed,
Netscape shows a blank page but IE displays the result..
function displayresult()
{
for (var b = 0; b <= index; b++){
var userinput = new String(userans[b]);
var ansval = new String(ans[b]);
if (trim(ansval) == trim(userinput)) result = result +
10;
}
alert(result);
document.write ("The marks you have scored is: "+
result);
document.write('<html><head>');
document.write('<link rel="stylesheet" type="text/css"
href="../Style.css">');
document.write('</head><body bgcolor="#000000"
link="#C0C0C0" vlink="#C0C0C0" text="#FFFF00">');
document.write('</form></body>');
}
with regards,
arun
Lucid Software ltd.
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20