Jump to content

[SOLVED] appendChild()


therealwesfoster

Recommended Posts

ifrm = document.createElement("IFRAME");
...
...
...

 

This works:

document.body.appendChild(ifrm);

 

This doesnt:

document.getElementsByTagName('font')[10].appendChild(ifrm);

 

I get no errors, but when I view the source, it hasn't appended to the html anywhere. ??? I'm needing it to append the IFRAME inside of the font tags instead of the body (because of an IE error).. but it's not working..

 

help please

Link to comment
Share on other sites

The entire file is pretty long so here is the jist

 

<html>
<head>
  <title>title</title>
</head>

<body>

<table align="center">
<tr>
  <td colspan="2">

   <table align="center">
    <tr>
     <td>header stuff</td>
    </tr>
   </table><br/>

  </td>
</tr>
<tr>
  <td>

   <table align="center">
    <tr>
     <td>left area text and images</td>
     <td>...<font class="iframe_info"><script src="javascript.js"></script></font></td>
    </tr>
   </table>

  </td>
</tr>
</table>

</body>
</html>

 

See, I can't use document.body.appendChild() between the font tags because of this ( http://support.microsoft.com/default.aspx/kb/927917 ).. so i must either move the script's calling, OR, do something like document.getElementsByTagName('font')[10].appendChild(ifrm);

 

I hope that helps a little bit more

Link to comment
Share on other sites

here you go:

 

<html>
<head> <title>title</title>

<script language="javascript">
function insertFrame()
{
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "http://google.com/");
ifrm.setAttribute("frameborder", "0");
ifrm.setAttribute("name", "gf");
ifrm.style.width = 300+"px";
ifrm.style.height = 300+"px";
document.getElementsByTagName('font')[0].appendChild(ifrm);
}
</script>

</head>

<body onload="insertFrame()">
<table align="center">
<tr>
<td colspan="2">

<table align="center">
<tr>
<td>header stuff</td>
</tr>
</table><br/>

</td>
</tr>
<tr>
<td>

<table align="center">
<tr>
<td>left area text and images</td>
<td>...<font class="iframe_info"></font></td>
</tr>
</table>

</td>
</tr>
</table>

</body>
</html>

 

I had to go back to you previous code. See how this code turns out for you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.