Jump to content

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
https://forums.phpfreaks.com/topic/80522-solved-appendchild/
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
https://forums.phpfreaks.com/topic/80522-solved-appendchild/#findComment-408319
Share on other sites

Didn't we solve this sample type of question a couple of days ago? I am not trying to come off smart with this question; but I think you could do this similar to this thread:

 

http://www.phpfreaks.com/forums/index.php/topic,170732.msg755024.html#msg755024

 

I like to try to find the easiest way to do things.

Link to comment
https://forums.phpfreaks.com/topic/80522-solved-appendchild/#findComment-408329
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
https://forums.phpfreaks.com/topic/80522-solved-appendchild/#findComment-408341
Share on other sites

I think your going to have to call the appendChild some way or the other with a function; I think that is the only way you can do this - maybe because of a browser security feature. I'm not 100% about this; but if you can find a better way and make it function like you want it to - then by all means do it.

Link to comment
https://forums.phpfreaks.com/topic/80522-solved-appendchild/#findComment-408366
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.