Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Pass parameter between pages in different domains (with access to both) (http://www.velocityreviews.com/forums/t874218-pass-parameter-between-pages-in-different-domains-with-access-to-both.html)

WeAreGoing! 12-01-2003 02:22 AM

Pass parameter between pages in different domains (with access to both)
 
Hello. I need to transfer an MD5 digest number between two pages on
different domains. I know this is generally not possible, but I have full
access on one domain and can insert Javascript at will into tha pages of the
other. I'd like to be able to store the number into a cookie for retrieval
by either set of pages.

I've been racking my brains for a couple of days on this one and just can't
come up with the answer.

Thanks in advance!




Lasse Reichstein Nielsen 12-01-2003 07:12 AM

Re: Pass parameter between pages in different domains (with accessto both)
 
"WeAreGoing!" <nospam@reply-to-group.com> writes:

> Hello. I need to transfer an MD5 digest number between two pages on
> different domains. I know this is generally not possible, but I have full
> access on one domain and can insert Javascript at will into tha pages of the
> other.
> I'd like to be able to store the number into a cookie for retrieval
> by either set of pages.


Instead of trying to dodge the different-domain security settings,
which will probably not work consistently across browsers, or even
survive a patch, I would do something simpler:
Let the page that sets the cookie also load a page from the other
domain. Pass the number in the search string to that page.

You will then end up with different cookies for the different domains,
so you must keep them synchronized.

Example code:
On page in first domain:
---
function setCookieOtherDomain(cookie,returnUrl) {
location.href = "http://www.otherdomain.com/"+
"setCookieFromFirstDomain.html"+
"?cookie="+escape(cookie)"+
"&return="+escape(returnUrl);
}
---
On setCookie page in other domain:
---
<script type='text/javascript'>
function parseInput(input) { // works for search or cookies
var data = {};
if (input == "") {return data;}
var inputs = input.split("&");
for (var i in inputs) {
var parts = inputs[i].split("=");
data[unescape(parts[0])]=unescape(parts[1]);
}
return data;
}
var input = parseInput(location.search.substr(1));
setCookieFunction("cookie",input["cookie"]); // some function you define
location.href = input["return"];
</script>
---
(untested)

Good luck.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


All times are GMT. The time now is 09:27 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.