Click to See Complete Forum and Search --> : Strange about Netscape 7.02


mf22cs
04-14-2003, 03:39 PM
Take a look att this simple code:

<html>
<head>
<title>Untitled Document</title>
<script language="JavaScript">
<!--
function testare() {
document.write(document.forms[0].elements[0].value);
}
//-->
</script>
</head>
<body>
<form>
<input type="text" value="saedhdh" />
</form>
<p><a href="javascript:testare()">test</a></p>
</body>
</html>

This works good in IE6 (SP1), but "fails" in NN7.02.

The problem seems to be the line "document.write...".

In IE the loading stops as soon as this line is executed, but in NN7 it just goes on and on... (doing nothing).

Is this a known error in NN or is there something wrong in my code. :confused:

The real code is longer and includes writing to popups, and so on... but to show the problem I wrote this simple code.

Greetings
/Marcus

khalidali63
04-14-2003, 04:27 PM
Proper way if using statement is

document.open();
document.write(document.forms[0].elements[0].value);
document.close();
this will solve your problem

Cheers

Khalid

mf22cs
04-15-2003, 01:39 AM
Don't work...

document.open(); makes the document.forms[0]... to be invalid.

/Marcus

AdamGundry
04-15-2003, 02:06 AM
How about this?

function testare() {
var frmval = document.forms[0].elements[0].value;
document.open();
document.write(frmval);
document.close();
}

Adam

mf22cs
04-15-2003, 03:27 AM
That seems to work (have not tried yet, but will do). :D

Thanks!
/Marcus

khalidali63
04-15-2003, 07:36 AM
Originally posted by mf22cs
Don't work...

document.open(); makes the document.forms[0]... to be invalid.

/Marcus

This meas there is something else wrong in your code which is not posted here.The snippet I posted above will work provided there is at least 1 form in the page and this form have 1 element that has a value attribue.

:confused:

Cheers

Khalid