Quickest way to pass data to a popup window I created using window.open()?

Assuming it's the same domain, do what Bart said. If it's a different domain, you can use the hash tag to pass some data, eg http://www.example.com/page#some_data_for_the_page. You could URL encode key/value pairs if you have enough data to warrant that.


Due to security restrictions it is super easy only if the parent window and the popup are from the same domain. If that is the case just use this:

// Store the return of the `open` command in a variable
var newWindow = window.open('http://www.mydomain.com');

// Access it using its variable
newWindow.my_special_setting = "Hello World";

In the child (popup) window, you could access that variable like this:

window.my_special_setting

Was there something specific you wanted to do past that?

Tags:

Javascript