[Greasemonkey] XMLHttpRequest and document.domain

Saravanan saravanannkl at gmail.com
Mon Jul 25 11:19:36 EDT 2005


>> I'm sorry, but I don't have time to wade into that morass of frames and 
scripts on the indiatimes.com <http://indiatimes.com> homepage, I don't know 
the error you *are* getting, and your script and what 
you're trying to do with it are opaque to me, possibly because I'm dumb. I 
still think the error on req.open() is fundamentally the result of 
cross-domain requesting.

Instead of throwing a link printer friendly page, my script tries to show 
the whole article in a single page while preserving the contents in the 
existing page. I am doing this because in printer friendly page you wont get 
link to other news stories or other sections. 

*Theoratically req.open is not cross-domain request* because I am in 
timesofindia.indiatimes.com <http://timesofindia.indiatimes.com> website 
page and my script makes a request to the same domain 
timesofindia.indiatimes.com <http://timesofindia.indiatimes.com>. since the 
document.domain value got changed to a lower level domain
(indiatimes.com<http://indiatimes.com>)
in the page, mozilla thorws exception for req.open. To fix this I tried to 
change the document.domain to the original value "
timesofindia.indiatimes.com <http://timesofindia.indiatimes.com>". As 
explained by Lenny, mozilla is not allowing to change the
document.domainfrom lower level domain to higher level domain even
though my page is in the
higher level domain.

>>I'm not sure why the browser doesn't remember what the original domain was 
and therefore to reset the original...
Should I file a bug for this ?



On 7/25/05, Jeremy Dunck <jdunck at gmail.com> wrote:
> 
> On 7/24/05, Lenny Domnitser <ldrhcp at gmail.com> wrote:
> > I do not know why changing document.domain is allowed or useful, but
> > the Times of India website has this code:
> 
> It's useful because it affects which requests also include cookies:
> cookies are set for particular domains and paths. A cookie set on
> foo.bar.com <http://foo.bar.com> will not go to bar.com <http://bar.com>, 
> but a cookie set on bar.com <http://bar.com> will
> go to requests of foo.bar.com <http://foo.bar.com>.
> 
> I'm not sure why the browser doesn't remember what the original domain
> was and therefore to reset the original...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050725/ce5a8d31/attachment-0001.htm


More information about the Greasemonkey mailing list