Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9373 (new defect)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Ajax.Request does not handle the base tag in Opera

Reported by: xmedeko Assigned to: sam
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: normal Keywords:
Cc:

Description

Hi,

I have a html with the base tag <base href="http://localhost/trunk/" /> in the head. When I use Ajax.Request('some/relative/url', ...), then the 'some/relative/url' is appended to the URL os the page, and not the base URL in Opera 9.23. So, I have to use workaround like

url = $$('base')[0].readAttribute('href') + 'some/relative/url'; Ajax.Request(url,...);

Attachments

ajax_opera_base_uri.diff (0.7 kB) - added by jdalton on 03/30/08 06:20:07.

Change History

08/25/07 05:08:42 changed by xmedeko

I've just discovered, that if the base tag is without the last slash:

<base href="http://localhost/trunk/" >

then Opera works fine, too.

08/25/07 05:39:02 changed by xmedeko

Erhm, no, it does not work event with modified base tag. Sorry, for confusing information. Maybe try to reproduce by yourself.

09/18/07 08:11:34 changed by xmedeko

And here's the solution (ehm, workaround):

if (Prototype.Browser.Opera) { var base = $(document.documentElement).down('base'); document.baseURI = base.readAttribute('href'); }

Ajax.Responders.register({

onCreate: function(req){

if (Prototype.Browser.Opera) {

req.url = document.baseURI + req.url;

}

}

}

01/24/08 04:16:54 changed by fearphage

This is a bug in the 9.2x (maybe older) branch of Opera. It was filed as Opera bug #309119. It works properly in the latest unstable builds of 9.5x.

03/30/08 06:20:07 changed by jdalton

  • attachment ajax_opera_base_uri.diff added.

03/30/08 06:20:48 changed by jdalton

  • summary changed from Ajax.Request does not handle the base tag in Opera to [PATCH] Ajax.Request does not handle the base tag in Opera.

03/30/08 16:17:14 changed by fearphage

The only problem with the patch is that it is unnecessary in the Opera Kestrel (9.5) which is the next version coming out (Public snapshots are available for download). It is only needed in versions less than 9.5. It would be nice if prototype stored version information in Prototype.Browser.* instead of merely boolean values. So you would need to detect that to make it right.

if (Prototype.Browser.Opera && window.opera &&
    opera.version && (opera.version() < 9.5)) { /* do stuff */ }

03/30/08 16:22:54 changed by fearphage

Actually

if (Prototype.Browser.Opera && opera.version &&
 (opera.version() < 9.5)) { /* do stuff */ }

Alternatively, you could grab the version info from the userAgent.