problem with getElementsByName

L

lukaszmn

Hi, I cannot figure out why everything from line "var elem =
doc.getElementsByName('keywords')" in x.js is not executed. I want to
set value of <input name=keywords ...> which is in a.html after page
is loaded.

------------------ search.html --------------------

<html>
<head>
<title>Search</title>
<script src="x.js"/>
</head>

<frameset rows="*" onload="load()">
<frame src="search-1.html"/>
</frameset>

</html>


------------------- search-1.html -------------------------

<html>
<head>
<title>Search</title>
</head>
<body>

<iframe src="a.html" height="600" width="600" id="frameSearch">
</iframe>


</body>
</html>



----------------- a.html --------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MLdonkey: Web Interface</title>
</head>
<body>
<form action="submit">
<input type=text name=keywords size=40 value="">
</form></html>



----------------------------------- x.js
-------------------------------

function load() {
var frame = frames[1].document.getElementById('frameSearch');
var doc = frame.document;
var elem = doc.getElementsByName('keywords');
alert (elem.length);
}
 
T

Tom de Neef

Hi, I cannot figure out why everything from line "var elem =
doc.getElementsByName('keywords')" in x.js is not executed. I want to
set value of <input name=keywords ...> which is in a.html after page
is loaded.

function load() {
var frame = frames[1].document.getElementById('frameSearch');
var doc = frame.document;
var elem = doc.getElementsByName('keywords');
alert (elem.length);
}

getElementsByName -> getElementByName
Tom
 
T

Thomas 'PointedEars' Lahn

Hi, I cannot figure out why everything from line "var elem =
doc.getElementsByName('keywords')" in x.js is not executed.
I want to [...]
[Invalid markup]

,-<http://jibbering.com/faq/#FAQ4_43>
| 4.43 How do I get my browser to report javascript errors?

Is there a point in your posting much the same twice under different authorship?

,-<http://jibbering.com/faq/#FAQ2_3>
| 2.3 What do I have to do before posting to clj?


PointedEars
 
J

Janwillem Borleffs

(e-mail address removed) schreef:
<title>Search</title>
<script src="x.js"/>

The script tag MUST be in the form <script ...></script> (so, with an
explicit closing tag)


JW
 
B

bbla32

Thank you all for suggestions. The problem was the IFRAME hadn't been
loaded before calling the script. I have not found a way to add an
onload event to the IFRAME, so I decided to use a timeout event.
 
R

Richard Cornford

1.) As Janwilliem stated, the script tag must be closed in IE
due to this bug:
<snip>

It is not a bug for an HTML parser not to be able to cope with a mark-up
structure that is not allowed in valid HTML.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top