/    Sign up×
Community /Pin to ProfileBookmark

How do I manipulate a Iframe

I’d like to know how to manipulate an iframe. Seems to me it should be a document element within the main document, but I do not know what code to use to access it. So far, I’m using the declaration:

[code=php]var worker=document.getElementById(“worker”);[/code]

to access the iframe. I want to be able to dynamicly choose a page to load in the iframe (complete), detect when the page is finished loading, and manipulate data within the iframe. The last two, I am unsure how to do. Can someone please enlighten me?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 07.2006 — there are two different objects down there:

1. the iframe object (the tag <iframe>)

2. the page loaded in iframe

Now, to handle the iframe object, the reference is

var myIframe=document.getElementById('iframeid')

to handle the window loaded in iframe, the window's reference is:

var myWin = document.getElementById('iframe').[B]contentWindow[/B]

Of course, the last reference works only if both the parent page and the loaded in iframe page belong to the same domain.
Copy linkTweet thisAlerts:
@KulagauthorMar 07.2006 — Of course, the last reference works only if both the parent page and the loaded in iframe page belong to the same domain.[/quote]

Unfortunatly, they are not. Is there anyway I can get around that?
Copy linkTweet thisAlerts:
@KorMar 07.2006 — Nope. For obvious security reasons you can not access/modify someone else's page... You might try extended AJAX (AJAX+php), but if you are not a good coder, I would not advice to use it, is a little bit dangerous.
Copy linkTweet thisAlerts:
@KulagauthorMar 07.2006 — How do I use extended AJAX. And what are the risks?

Basically, I just want to POST some data to the site, and display a response.
×

Success!

Help @Kulag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...