...

View Full Version : I have a problem with a javascript script.?



gogelpot
06-16-2008, 02:29 PM
I have 2 iframes id="Frame" and id="Frameinfo".
My script is very simple:

Code:

function update(url){
document.getElementById('Frameinfo').src=url
}
This function is activated by
Code:

onLoad="update('inbox.php')"
Now I get tis error:
document.getElementById(...) is null or not an object

What am I missing here?

vwphillips
06-16-2008, 02:49 PM
check that the id of id=Frameinfo is indeed Frameinfo and id="Frameinfo" is not repeated in the document.

gogelpot
06-16-2008, 02:58 PM
Allow me to give you the full code:

Main page code (Parent window):


<center><iframe name="Frame" id="Frame" SRC="blank.html" width=950 height=60 frameborder=1 marginwidth=0 marginhight=0 frameborder=0 Scrolling="no"></center>
<center><iframe name="Frameinfo" id="Frameinfo" SRC="blank.html" width=950 height=420 frameborder=1 marginwidth=0 marginhight=0 Scrolling="yes"></center>


Code in iFrame id=Frame:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script language="Javascript">
function update(url){
document.getElementById('Parent.Femeinfo').src=url
}
</script>
</head>

<body bgcolor=#a5b395 onLoad="update('Inbox.php')">
<br>
<table border=1 width=930>
<tr>
<td width=40 height=30>
<b><center>Urgent</center></b>
</td>
<td width=450>
<b><center>Subject</center></b>
</td>
<td width=250>
<b><center>From</center></b>
</td>
<td width=150>
<b><center>Time Posted</center></b>
</td>
<td width=40>
<b><center>Read</center></b>
</td>
</tr>
</table>

</body>
</html>


I hope this will help. I am totaly lost nd new to javascript.

Mr J
06-16-2008, 08:56 PM
Change this line

document.getElementById('Parent.Femeinfo').src=url

to

parent.document.getElementById('Frameinfo').src=url


see if that works

Trinithis
06-16-2008, 10:16 PM
Irrelevant to your problem, I would also like to point out with your

<script language="Javascript">
to use the following instead:

<script type="text/javascript">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum