felix Antony
felix Antony

Reputation: 1460

Access master page from child iframe src page

I have two pages "childpage" and "pageforIFrame". here childpage is the child of a master page "Master1". on the child page I have an IFRAME, its src is pageforIFrame. On the button click of pageforIFrame button i want the label inside the master page. Is it possible?

enter image description here

Thanks in advance.....

Upvotes: 0

Views: 2429

Answers (3)

Jinesh Jain
Jinesh Jain

Reputation: 1242

try to write this
$("#IfrmaeID").contents().find("#ElementID")
alert this and if this give object you can assign any value.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Is it possible?

Yes, if the two applications are hosted on the same domain. You could access the parent DOM from the iframe like this:

window.parent.document.getElementById...

Upvotes: 1

K D
K D

Reputation: 5989

You can access the parent page from the iframe like this. considering your myLabel has id="myLabel" place this code in your iframe script tag for click of button

alert(top.document.getElementById('myLabel'));

and chagne the label

top.document.getElementById('myLabel').innerHTML = "Hello";

Upvotes: 1

Related Questions