Jump to content


Photo

dynamic frames


  • Please log in to reply
2 replies to this topic

#1 Hokus

Hokus
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationAlameda, CA, USA

Posted 31 August 2006 - 07:04 AM

Hello,

I'm trying to create multiple iFrames with javascript to do some serverside stuff in the background. when I want to dynamically create a 2nd or 3rd iframe within a div, i have to "reload" the contents of the div, which means ALL the iframes will refresh ... so, is there a way to dynamically insert an iframe outside of a tag?

this is what i'm using:

function numForms()
{
str = document.getElementById('numForm').innerHTML
document.getElementById('numForm').innerHTML = str + '<iframe class=\"hideFrame\" src=\"iframe.php\">';
}

I need the previously generated iframes NOT to refresh when I dynamically add another.

Hope it makes sense .. just started playing around with JS.

Thanks!
[!--sizeo:2--][span style="font-size:10pt;line-height:100%"][!--/sizeo--][!--fonto:Arial--][span style="font-family:Arial"][!--/fonto--][!--coloro:blue--][span style="color:blue"][!--/coloro--]"Experience is a wonderful thing. It enables you to recognize a mistake when you make it again".
[!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--][!--fontc--][/span][!--/fontc--]

#2 expertsystems

expertsystems
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 01 September 2006 - 09:09 AM

hi,
You can use standard DOM methods for adding elements into the page. I feel, using innerHTML shouldn't be a preferred way. Instead, use
document.createElement(IFRAME) and document.divname.appendChild(varname).
For eg. to add a iframe dynamically in a page on a button click, see following function. To the function I am passing the id of the div to which the frame will be appended.

function addIFrame(divid) {
var newiframe=document.createElement(IFRAME); //IFRAME without quotes
newiframe.id="iframe1";
newiframe.src="http://www.google.co.in"; //replcace as required
div1=document.getElementById(divid);
div1.appendChild(newiframe);
}




#3 Hokus

Hokus
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationAlameda, CA, USA

Posted 02 September 2006 - 05:05 AM

thank you, just what i was looking for.
[!--sizeo:2--][span style="font-size:10pt;line-height:100%"][!--/sizeo--][!--fonto:Arial--][span style="font-family:Arial"][!--/fonto--][!--coloro:blue--][span style="color:blue"][!--/coloro--]"Experience is a wonderful thing. It enables you to recognize a mistake when you make it again".
[!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--][!--fontc--][/span][!--/fontc--]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users