Jump to content

[SOLVED] Is it possible for an iframe to call for the update of another iframe?


janusmccarthy

Recommended Posts

Currently all the technical pieces are correct.  It's more of a "how to" question than a code assist.  I've inherited this code and while I understand it, it's spread out over several files and the chances of it being posted in its entirety is slim.

 

I currently have a dialog that shows two iframes.  One iframe shows the contents of the "file" directory, one iframe shows the contents of the "archive" directory.  The control that sends a file to the "archive" directory is on the dialog.  The control that restores the archive to the "file" directory is in the archive iframe itself.

 

Currently when a file is archived, both frames are called to refresh by the dialog.  However, when a file is restored from archive, because the control that restores the archive exists in the iframe, only the archive iframe is being refreshed.

 

Is there a way to propagate the need to refresh to the "file" iframe?  I just don't see how.

 

Any help is appreciated.

 

/////////////////////////////////////////////

To organize the information another way and for additional information....

/////////////////////////////////////////////

 

DIALOG

------------

The dialog contains two iframes, FRAME A and FRAME B.

The dialog also contains a button that when clicked, sets a POST variable denoting the need to archive, then submits on FRAME A then FRAME B.

 

FRAME A

----------

Frame A's script displays the contents of the "File" directory.

When the DIALOG submits to Frame A, Frame A generates a ZIP SCRIPT, then jumps to the script. 

When the ZIP SCRIPT returns to Frame A, Frame A removes the ZIP SCRIPT, then displays the contents of the "File" directory.

 

FRAME B

----------

Frame B's script displays the contents of the "Archive" directory.

Each archived file in Frame B has a RESTORE_BUTTON which returns a file to the "Files" directory.

When the DIALOG submits to Frame B, Frame B checks to see if the ZIP SCRIPT exists.  If it does, it reloads and checks later.  If it doesn't, then it displays the contents of the "Archive" directory.

When the RESTORE_BUTTON is pressed, Frame B generates a RESTORE_SCRIPT and jumps to it.

When the RESTORE_SCRIPT returns to Frame B, Frame B removes the RESTORE_SCRIPT, then displays the contents of the "Archive" directory.

 

Link to comment
Share on other sites

Yes, in your javascript simply preface the frame name (or target for forms).  So, for example:

 

For frame1 to modify frame2,

 

frame2.window.location='my-new-url'

 

This assumes that this exists: <iframe name='frame2'>...

 

Alright, I've tried this, and I don't seem to be doing it right.

 

In the dialog script, I added the name field to the iframe and gave it the value "userdocs"

In the script for FRAME B, in the body of the html document, I've added:

 

(if doing a restore)
$sm->log_debug( "Calling file listing refresh.");  //Call my log file.
echo "<script language=javascript>userdocs.window.location='PETE/testpages.php?whose=user';</script>";

 

I can see the log message hit the log.  I'm receiving a message from firebug 'userdocs is not defined.'

 

What could I be missing?  Do I need to put the frames within a frameset or otherwise take extra steps to ensure they can see each other?  Do I need to go through the containing page somehow?

Link to comment
Share on other sites

Okay, I figured it out on my own.

 

In short, it seems to work if you make sure to create a named object hierarchy for javascript to find the path.

 

[*]In the page containing the two frames...

 


  •    
  • Use a named frameset
       
  • Make sure each of the iframes have a name (for this example envision a frame named LEFT and a frame named RIGHT.
     

 

[*]To call one frame from the other frame...(for this example envision that LEFT calls RIGHT to refresh)

 


  •    
  • Place the following call in the body of the html page:   
       



      echo "<script language=javascript>parent.RIGHT.window.location.reload();</script>"
   


    •  
       

 

 

Note that if the script you're calling uses the $_SET variable, you may to set the location directly and pass in your set.

 

Before I wasn't using a named frameset and couldn't reference either parent or RIGHT directly. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.