Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a window, then read its contents?

Status
Not open for further replies.

tystent

Programmer
Jan 25, 1999
15
0
0
US
After creating another window from JS, can I capture its events? Can I read its document?
 
The events happen in the new window. You can report them to the parent window using an event handler in the new window.

If something happens in the parent window it can "read" the document in the new window.

The essential thing is to name the new window in the window.open() method, then you can reference it by name in a script in the parent window. Scripts in the new window can reference things in the parent window as
parent.document.this_or_that_thing .
 
The webpage for the new window is from another server, not under my control. So I can't modify it. I've tried AJAX but run into the cross-domain permission problem, so I'm trying to find a way around it.

When opening the child window from the parent, can I specify something in its attributes that will connect one of its events (say, onLoad) to an event handler in the parent window.
ala,
Code:
  var newwin = window.open("thatotherpage.htm", "crazychild", "onLoad=childLoadedEventHandler");
or are attributes just for shaping and sizing the child window?

 
correction, I meant the sample attribute string to say
Code:
"onLoad=[aqua]parent.[/aqua]childLoadedEventHandler"
 
another correction, I meant
Code:
"onLoad=[red]opener[/red].childLoadedEventHandler"

But I'm abandoning this line of attack (against the AJAX cross-domain barrier) because it's been pointed out that many people disable popups entirely. Maybe I'll try a tiny, hidden iframe...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top