Topic: trying to reload iframe from other iframe (Page 1 of 1) Pages that link to <a href="http://www.ozoneasylum.com/backlink?for=30892" title="Pages that link to Topic: trying to reload iframe from other iframe (Page 1 of 1)" rel="nofollow" >Topic: trying to reload iframe from other iframe <span class="small">(Page 1 of 1)</span>\

 
nakins
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2006

IP logged posted posted 03-03-2009 17:59 Edit Quote

I'm trying to reload a page in an iframe (a content page) from a page in another iframe (hidden, that checks for updates). The parent for both of these iframes is the main window. I'm trying to do this with javascript. The following is the source code that loads into iframe fr1, which is trying to reload iframe fr2.

code:
function updateWindow() {
window.frames[fr2].location = url;
} 
window.onload = updateWindow;



But this doesn't seem to be working. What am I doing wrong here?

Kyle the Feared
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jan 2009

IP logged posted posted 03-04-2009 06:18 Edit Quote

If that code is loaded in the first frame, then window.frames is a reference to the first frame's frames (I assume it has none).
To get the frames of the main window, you will need to use parent.frames.
And if you had multiple levels of frames, you could get to the main by using top.frames.

Also, I'm assuming fr2 is a global variable defined in the top frame?
If so, then you will need to reference it as parent.fr2 or top.fr2.

This may help you.
http://www.oreillynet.com/pub/a/javascript/excerpt/jstdg_ch13/index.html?page=7#multwinfram

(Edited by Kyle the Feared on 03-04-2009 06:19)

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 03-04-2009 12:15 Edit Quote

Beside, I'm wondering what's the use case for frames & iframes these days beside sandboxing web widgets and ads. Since you already require JavaScript to be enabled, surely you XHR chunks of information and dynamically update parts of the of page. After all it's the 21st century and all.

yossiadmon
Obsessive-Compulsive (I) Inmate

From: Israel
Insane since: Sep 2009

IP logged posted posted 09-07-2009 18:28 Edit Quote

Just give the frame / iframe a name and submit a form with target="frame name" it will work regardless to the frame level
(I won't ask why using frames...)



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu