SageFix. LetsFix!  
Current Location : Home > Web Development > JavaScript > Call a function in another window Share/Save/Bookmark    

Main Menu
SageFix - Let's Fix

Board Categories
    Web Site Designing
- Graphics
    Web Development
- .NET
- Classic ASP
- JavaScript
- PHP
    WebSite Management
- Promotion Techniques
- Search Engine Optimization
    Databases
- MySQL

Tutorials

Database Connection Strings

  Contact Us


 1 - 10 of 10 [Total 1 Pages]  
Call a function in another window      Jul 27, 2002, 11:38 1
  
Hi!
Is it possible to call a window's function from another window? E.g. refresh ...or any other Javascript function?

thx in advance
Chrisi

 
      Jul 29, 2002, 02:09 2
  
Nope - it's not the chat script.

It's in a system where there's about six or seven
frames and iframes within each other.

You obviously couldn't use top.funciotn - coz it's not
the top window.
You can't call it by windowname - coz i want to be able
to know how many levels up it is ( and show that in the code for other people ).

Flawless

 
      Jul 27, 2002, 15:04 3
  
As long as you have a handle to the window then it's no probs (frames within the same window may be accessed via the DOM)!
Code:
windowhandle.document.location.refresh();

 
      Jul 27, 2002, 16:57 4
  
thx
and how can I call the parent window from inside the popup's code? i'm asking because window.open is the only way I know to get a windowhandle.

chrisi

 
      Jul 28, 2002, 00:49 5
  
The syntax for addressing the popup's opener is:
window.opener
-OR-
self.opener
-OR-
top.opener
-OR-
parent.opener

Depending on how you need to reference it. All are valid if frames are not present in the popup. 'parent' will work if there is only 1 framset, otherwise 'top' will be needed.

So, if you wanted to refresh the opening document:
window.opener.location.refresh();

 
      Jul 28, 2002, 06:30 6
  
I'm currently working on a project that requires:
window.parent.parent.parent.parent.function();



Flawless

 
      Jul 28, 2002, 07:57 7
  
top.function() should be able to replace that, shouldn't it?

 
      Jul 28, 2002, 08:09 8
  
Quote:

I'm currently working on a project that requires:
window.parent.parent.parent.parent.function();



Flawless
lol that the chat script,

i do like these ones tho

this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentN ode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNo de.parentNode.parentNode.innerHTML

lol

 
      Jul 28, 2002, 09:49 9
  
Maybe I'm missing something, but wouldn't it be simpler to use...
Code:
window.name="parentWindowName"
...in the parent window itself and then simply refer to that window by using whatever name you gave it?

Surely this would be better than a string of parent.parent.parent... or opener references and easier to keep track of too.

Just a thought

 
      Jul 28, 2002, 10:10 10
  
I agree with you Bill 100%

If you reference the window more than once, or there are multiple windows you need to name them

 
 1 - 10 of 10 [Total 1 Pages]  









Subscribe to our mailing list
email


Current Location : Home > Web Development > JavaScript > Call a function in another window Share/Save/Bookmark    

Development problem? SageFix is completely free -- paid for by advertisers and donations. Click here to Contact Us If you have any query. Enjoy!
Request processed in 8.0E-5 seconds Home - Contact Us - Terms Of Service - Privacy Policy - Copyrights - Top
Advertisements do not imply our endorsement of that product or service.
Current server time now is 11-Mar-2010 23:09:34
Copyright © 2009 Sagefix Inc. All rights reserved.
Powered By SageFix