W3C home > Mailing lists > Public > public-webapi@w3.org > February 2006

Re: ISSUE-29: how is uri parameter of the open() method resolved

From: Sjoerd Visscher <sjoerd@w3future.com>
Date: Tue, 28 Feb 2006 23:47:50 +0100
Message-ID: <4404D316.5060207@w3future.com>
To: Jonas Sicking <jonas@sicking.cc>
CC: Anne van Kesteren <annevk@opera.com>, Web APIs WG <public-webapi@w3.org>

> file1.html:
> <iframe src="file2.html" id="frame"></iframe>
> <script>
> document.body.onload = function() {
>   document.getElementById('frame').contentWindow.doIt('./test.xml');
> }
> </script>
> 
> 
> file2.html:
> <script>
> function doIt(uri) {
>   xhr = new XMLHttpRequest();
>   xhr.open('GET', uri, false);
>   return xhr.responseXML;
> }
> </script>
> 
> 
> Should the uri "./test.xml" be resolved against "file1.html" or
> 'file2.html'. This is a real issue and something that people actually
> do. There is no way to always get this 'right' since the uri-string
> could have just as well come from file2.html.
> 
> In mozilla we actually use file1.html as baseURI, though I would argue
> that we should use file2.html.

To get it perfectly right every string should have a base URI property. 
String literals get the base URI of the script element they are in. But 
then you would have to do this for every string generating item in the 
browser. F.e. the base URI of a string from input.value should probably 
be the base URI of the input element.

In any case I don't think it is correct to choose between windows, you 
should choose between base URIs of script elements.

-- 
Sjoerd Visscher
http://w3future.com/weblog/
Received on Tuesday, 28 February 2006 22:48:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:53 GMT