Craig <craig@_netscen e.org> wrote in message news:<Ce******* ************@ne ws20.bellglobal .com>...
Hey all,
Here's the situation:
- two websites, one on domain1 and the other on domain2
- domain1 opens a new window which is a javascript app from domain2
- domain1 needs to communicate with the javascript app on domain2
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="http://domain2/page2.html" method="get"
target="whateve r">
<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
http://domain2/page2.html?x=23&y=abc
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
http://domain2/page2.html you need to decode the
search string (and here's code based on "something I prepared
earlier").
var submission=self .location.searc h.substring(1,s elf.location.se arch.length);
// remove "?" at start of query string
var nameValuePairs = new Array();
var oneNameValuePai r = 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.spli t(punctuator); // split into
name=value pairs
for (var i in nameValuePairs) {
oneNameValuePai r = nameValuePairs[i].split('=');
// separate name and value
if (oneNameValuePa ir[0].length>0) { // if a name to left of = sign
name = unescape( oneNameValuePai r[0] ).split("+").jo in(" ");
value = unescape( oneNameValuePai r[1] ).split("+").jo in(" ");
// 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