Opened 8 years ago

Closed 6 years ago

#4941 closed bug (fixed)

Mishandling of base tag

Reported by: ZeK Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.tabs Version: 1.8a1
Keywords: base tabs baseurl ui bug Cc:
Blocked by: Blocking:


Hello, i have some troubles with tabs, it doesn't manage well the base tag.

Let's say i have a page on and i set a base like this :

<base href="" />

So, if i want to have tabs, my link will look like this :

<a href="dir/page.html#mytab">My Tab</a>

But, jquery considers the tab like a remote tab.

The code is in ui.tabs.js, line 91 (on 1.8a1) :

if (hrefBase && (hrefBase === location.toString().split('#')[0] ||
(baseEl = $('base')[0]) && hrefBase === baseEl.href)) {

In my example :

I can't find any example where the second line could be true. But, what could work for the base, is that :

(baseEl = $('base')[0]) && location.toString().split('#')[0] == baseEl.href+hrefBase

I tested it, works in my case.


Change History (4)

comment:1 Changed 8 years ago by ZeK

My solution was a messy solution (it modifies the URL)

What seems to work better line 97 :

// inline tab
if (fragmentId.test(href)) {
	self.panels = self.panels.add(self._sanitizeSelector(href));

Changed by :

// inline tab
if (fragmentId.test(href) ||
(baseEl = $('base')[0]) && location.toString().split('#')[0] == baseEl.href+hrefBase) {
  self.panels = self.panels.add(self._sanitizeSelector(a.hash));

comment:2 Changed 8 years ago by Jörn Zaefferer

Milestone: TBD1.8

Consider using the same-domain check used by jQuery core for JSONP.

comment:3 Changed 6 years ago by mriffault

Here is how i fix this issue. The ZeK solution didn't works for me :

// inline tab
if( $('base')[0] ) {
  var locHref = location.href;
  nvar pURL = locHref.replace($('base')[0].href, '/');
if (fragmentId.test(href) ||
$('base')[0] && pURL == hrefBase ) {
  self.panels = self.panels.add(self._sanitizeSelector(a.hash));

I test if the hrefed page is the current page... So i think it is a good way to solve this problem...

Last edited 6 years ago by mriffault (previous) (diff)

comment:4 Changed 6 years ago by Scott González

Resolution: fixed
Status: newclosed

Tabs: Fixed detection of local vs. remote tabs. Fixes #4941 - Mishandling of base tag. Fixes #4836 - Self refering href only partially detected.

Changeset: 18a3b539882835ecc78ed976a7d9e830c128fd96

Note: See TracTickets for help on using tickets.