Bug 23876 - New-tab click uses current tab
Summary: New-tab click uses current tab
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 525.x (Safari 3.2)
Hardware: Mac (Intel) OS X 10.5
: P2 Normal
Assignee: Nobody
URL: http://varusonline.com/
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-10 12:44 PST by Jessica Hawkwell
Modified: 2009-07-27 15:51 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jessica Hawkwell 2009-02-10 12:44:42 PST
On the Quick Links menu (among other places), we have JavaScript links for memu items.  We are not the only site that uses JavaScript these click-anywhere links.  When middle-clicking a link that uses this method on any site, a new tab is opened, but the current tab also loads the destination page, very annoying when you only want the destination page to be loaded in a new tab.
Comment 1 Mark Rowe (bdash) 2009-02-10 13:05:33 PST
The source looks like:

<li onclick="document.location='/mygear/luggage.php';"><a href="/mygear/luggage.php">Luggage</a></li>

It's not clear why you think Safari's behaviour is incorrect.  It's certainly not what you intend, but the click event handler on the <li> element is navigating the current document.
Comment 2 Jessica Hawkwell 2009-02-10 13:31:26 PST
(In reply to comment #1)
> The source looks like:
> 
> <li onclick="document.location='/mygear/luggage.php';"><a
> href="/mygear/luggage.php">Luggage</a></li>
> 
> It's not clear why you think Safari's behaviour is incorrect.  It's certainly
> not what you intend, but the click event handler on the <li> element is
> navigating the current document.
> 

(In reply to comment #1)
> The source looks like:
> 
> <li onclick="document.location='/mygear/luggage.php';"><a
> href="/mygear/luggage.php">Luggage</a></li>
> 
> It's not clear why you think Safari's behaviour is incorrect.  It's certainly
> not what you intend, but the click event handler on the <li> element is
> navigating the current document.
> 

Other browsers handle it differently.  In other browsers, click processing stops after the new tab is opened.
Comment 3 Mark Rowe (bdash) 2009-02-10 13:40:17 PST
If you click on the <li> element outside of the <a> it contains you'll end up with the exact same problem.
Comment 4 Jessica Hawkwell 2009-02-10 13:47:44 PST
(In reply to comment #3)
> If you click on the <li> element outside of the <a> it contains you'll end up
> with the exact same problem.
> 

Aye, but the <a> is there so it CAN be middle-clicked.  Middle-clicking outside the <a> does nothing.  This is completely normal.
Comment 5 Mark Rowe (bdash) 2009-02-10 13:55:34 PST
On that basis the JavaScript on the <li> is completely redundant.
Comment 6 Jessica Hawkwell 2009-02-10 13:57:44 PST
(In reply to comment #5)
> On that basis the JavaScript on the <li> is completely redundant.
> 

No, the JavaScript in the <li> is there to provide click-anywhere.  The <a> is there so the menu item can be middle-clicked.  When the <a> is middle-clicked, the page should open in a new tab and the current tab should not be affected.
Comment 7 Mark Rowe (bdash) 2009-02-10 14:07:45 PST
So you can click anywhere, but only middle-click in certain places?..  It seems to me it would be better to make the entire clickable area the <a> element, then middle-click would work as expected on the entire link and you wouldn't need to involve JavaScript.
Comment 8 Jessica Hawkwell 2009-02-10 14:20:51 PST
(In reply to comment #7)
> So you can click anywhere, but only middle-click in certain places?..  It seems
> to me it would be better to make the entire clickable area the <a> element,
> then middle-click would work as expected on the entire link and you wouldn't
> need to involve JavaScript.
> 

How does one make <a> span the entire area?  Every time I've tried that, it only ends up being as large as the text, and in every browser I've tested.
Comment 9 Franck 2009-07-27 15:51:27 PDT
Same problem with plenty of other websites
See bug #18161 and #22382