Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Communicating via javascript across domains
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="grp_pst_363, post: 4716148"] Craig You could try to pass the information as a query string in the URL. Youy could either assemble a query string with JS or use a hidden form that submits using the get method. In a web page in domain1: <form name="myForm" action="[URL]http://domain2/page2.html[/URL]" method="get" target="whatever"> <input name="x" value="" type="hidden"> <input name="y" value="" type="hidden"> </form> To open the new window named "whatever" and pass over the info x=23 and y="abc": document.myForm.x.value=23; document.myForm.y.value="abc"; document.myForm.submit(); This should open the web page [URL]http://domain2/page2.html?x=23&y=abc[/URL] in the window called "whatever". Alternatively assemble the query string above and use it as the url for your window.open command. In the web page [URL]http://domain2/page2.html[/URL] you need to decode the search string (and here's code based on "something I prepared earlier"). var submission=self.location.search.substring(1,self.location.search.length); // remove "?" at start of query string var nameValuePairs = new Array(); var oneNameValuePair = new Array(); var names = new Array(); var values = new Array(); var name; var value; var newName; var punctuator="&"; // use "&" for query string or ";" for cookies nameValuePairs = submission.split(punctuator); // split into name=value pairs for (var i in nameValuePairs) { oneNameValuePair = nameValuePairs[i].split('='); // separate name and value if (oneNameValuePair[0].length>0) { // if a name to left of = sign name = unescape( oneNameValuePair[0] ).split("+").join(" "); value = unescape( oneNameValuePair[1] ).split("+").join(" "); // remove url encoding newName = true; for (var j in names) if (name == names[j]) newName = false; if (newName) { names[names.length] = name; values[name] = value; // single value with this name } else { values[name] = values[name] +","+value; // comma separated list of multiple values with this name } } } This gives (I hope) an array in domain2 web page called names containing "x" & "y" and an associative array called values where values["x"] is "23" and values["y"] is "abc". I've taken the above code from something I've used/tested previously but modified it without testing - CAVEAT EMPTOR. Hope that's of some use. Mark[/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Communicating via javascript across domains
Top