Notices

Water Fountain General Chit/Chat

Reply
 
LinkBack Thread Tools
Old 02-15-08, 01:28 AM   #1 (permalink)
Aximsite Prospect
 
Join Date: Feb 2008
Location: http://www.GlobalGuideLine.com
Posts: 1
Thanked 0 Times in 0 Posts
Aximsitemobileicon Accessing the iFrame Form elements.

I am trying to access the content of my iframe src page. Something
like below
Code:
document.getElementById('myFrame').contentWindow.document;
It works fine on a predifined iframe element, However, when creating
the iframe element
dynamically, and appending it to the body, I can't access the content
when doing this dynamic insertion. My guess would be that this is
because the iframe element doesn't yet exist on the Dom. See example
of problem below:

Code:
var myFrame = document.createElement("iframe");
myFrame.id = "testID";
myFrame.name = "testID";
myFrame.src = "testPage.htm";
myFrame.frameBorder = "0";

document.body.appendChild(myFrame);

//code below isn't working due to the above
document.getElementById('testID').contentWindow.document;
Does anyone have any example to access the elements of iFrame or Frame in browser
so I can do to resolve this issue?

Thanks
Ali
__________________
webmaster
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
ali_ggl is offline   Reply With Quote
Sponsor Ads
Old 02-15-08, 08:20 PM   #2 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
Man, I haven't seen iFrames for a long time, I guess they're still around.

What if you modify contentWindow.document to whatever you need before you append it?

It makes sense that the javascript would wait for the function to return before giving you access to that, because it doesn't wait for the src page to load before it goes to the next command.

You could always use Ajax and get rid of those iFrames :D
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- My Website

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I don't believe in atheists therefore atheists don't exist.
Clegs is offline   Reply With Quote
Reply

Tags
accessing, elements, form, iframe

Sponsor Ads

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:40 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC