user905234
user905234

Reputation: 43

Javascript Launch Popup and Fill a text field

I am struggling with this, hope something can shed some light.

On click of a button, I want to open a popup window, and transfer data from parent window to a text field in the popup. And, ensure popup is fully loaded before data is filled.

I tried using document.ReadyState=="complete", but it fires before the popup is fully loaded. I also tried to check the popup.body in a setTimeOut method, but to no avail.

Can you please help ?

PS: Popup window is a form from another domain !.

Upvotes: 3

Views: 483

Answers (1)

Phunky
Phunky

Reputation: 481

You won't be able to do this unless you control both domains due to XSS restrictions, but if you do control the content on both domains it's fairly simple with a bit of JS in the page you have opened in a frame.

Using window.opener in the frame will allow you to call any functions defined in the main window, this along with the seconds pages onload event is all you need to trigger a function when it loads.

If the content of the second page is not under your control the best thing you can do is an AJAX request which you will then need to be inserted into your page, this is a little nasty but will work.

Upvotes: 1

Related Questions