/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Opening Dom created in iframe in main(parent) page

Hi friends,
I am asking for my next question..
In page loaded into <iframe> ex. content.html I have function that creates a Dom-thats 1210x690px <div id=”bahrkutu”> with content.
I have to make appear this <div> in main(parent) page not in <iframe> itself. Anyone can help by giving some examples or tips?
This is <div id=”bahrkutu”>:

this is a link in iframe:

[COLOR=”Red”]<p><a href=”#” onclick=”myfunction();return false;”>link</a></p>[/COLOR]
I have to force [B]myfunction()[/B] to create div displayed below to open in parent page:

[CODE]<div id=”kutuoverlay” class=”kutuoverlay” onclick=”kapat_f();return false”></div>
<div id=”bahrkutu” class=”bahrkutu”>
<div id=”bahbaslik”>
<div id=”projeadi”>SOME TEXT</div>
<div id=”projeyilyer”>SOME TEXT-2</div>
<div id=”kapat” onclick=”kapat_f();return false”></div>
<div id=”zlogo” ></div>
</div>
<div id=”frameicerik”></div>
<div id=”solcizgi”></div>
<div id=”sagcizgi”></div>
<div id=”altcizgi”></div>
</div>[/CODE]

and this is function:

[CODE]
<script type=”text/javascript”>
function [COLOR=”Red”]myfunction()[/COLOR]{
$(‘kutuoverlay’).setStyle({‘display’: ‘block’});
$(‘bahrkutu’).morph(‘ height:690px;width:1210px;’);
$(‘bahrkutu’).insert(‘<div id=”frameicerik”></div>’);
$(‘projeadi’).replace(‘<div id=”projeadi”>REPLACED TEXT</div>’);
$(‘projeyilyer’).replace(‘<div id=”projeyilyer”>REPLACED TEXT-2</div>’);
setTimeout(function(){$(‘frameicerik’).insert(‘<iframe src=”some link” allowtransparency=”true” width=”100&#37;” height=”100%” scrolling=”no” frameborder=”0″ /> ‘);},1000);
}
</script>

[/CODE]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@mimartjauthorFeb 15.2009 — May be I was not so clear, the point is to get a DOM contained in iframe to open outside iframe. Or at least a way to control a DOM of parent(main) page from iframe...

[CODE]myfunction() make it myfunciton_outside();[/CODE]
Copy linkTweet thisAlerts:
@chestertbFeb 15.2009 — if you create a javascript function, let's call it "testit()", in your top page, you can access it from your iframe as follows...

top.testit()

You can access elements in the DOM of the iframe from the top by referring to them using the id of the iframe as follows. Let's make the iframe id='content'. Let's create an input field within the iframe, id='name'.

From the top window, you can acces the contents of 'name' as follows...

var n = content.document.getElementById('name').value;

Hope that helps.

CTB
Copy linkTweet thisAlerts:
@mimartjauthorFeb 16.2009 — hi chestertb,

As I understood you the "top" of [COLOR="Red"]top[/COLOR].myfunction(); is as an example if my main page name is top.html ??? or its something other?
Copy linkTweet thisAlerts:
@mimartjauthorFeb 16.2009 — Hey, I think it worked,thaks

Dom is located in main page and function for calling it too, in <iframe> when calling a function I use:
[CODE][COLOR="Red"]parent[/COLOR].myfunction()[/CODE]
or

[CODE][COLOR="Red"]top[/COLOR].myfunction()[/CODE]
Copy linkTweet thisAlerts:
@chestertbFeb 16.2009 — Yup. You've got it.

top. refers to a function on the top page of the iframe heirachy.

parent. refers to a function in the iframe immediately above the current location.

Cheers

CTB
×

Success!

Help @mimartj 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 5.21,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...