Matej Posted January 6, 2015 Share Posted January 6, 2015 Hello , lets say i have two sites 1) web.com 2) web.com/areyousure . Both have own stylesheets and js files. On first site (web.com) i use window.open("web.com/areyousure"). Is there any way to pass variables/functions to the second site from the parent site? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 6, 2015 Share Posted January 6, 2015 If you save a reference to the window when you open it then you can use that reference to access anything defined globally in the other window. Link to comment Share on other sites More sharing options...
Matej Posted January 6, 2015 Author Share Posted January 6, 2015 (edited) pass it like this? var parent="Im a parent site";var newSite=window.open("blabla.org");newSite.parentsite=parent;newSite.addEventListener("load",function(){alert(newsite.parentsite)},ture) If this is right way , what is right way to use passed variable/function on the opened site its like i used it (newsite.parentsite) or just simply using alert(parentsite)? // or you mean like this window.foo="im a parent site";window.open(" web.com/areyousure"); and just use "window.opener.foo" in newly opened window? Edited January 6, 2015 by Matej Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now