Alt-selecting links still opens them
-
- Hover over link.
- Hold down Alt.
- Press down left mouse button.
- Select part of the link.
- Release mouse button.
Expected: part of link stays selected, link doesn't open.
Actual: link is opened.Works on everything except oneboxes, as far as I can tell.
-
@Gąska Circumvent basic browser functionality and recreate it in Javascript, they said. It will be fine, they said.
As far as I know, the only reliable way to capture any action that activates a link, and only actions that activate the link, is to put
href="javascript:..."
. There's no "activated" event, and capturing things likeclick
means you have to manually filter out clicks that should or shouldn't activate the link, thus recreating what the browser does natively (which might vary from browser to browser, or change over time -- meaning that your script won't always match the native behavior). Plus, links can be activated by things other thank clicks -- the keyboard can also be used to highlight and activate a link.Of course,
href="javascript:..."
won't work if Javascript is disabled, and you'll need to include the originalhref
somehow. I think the ideal solution would probably be to sethref="whatever"
and then have a script change all of them tohref="ajax_load('whatever');"
. That way, users with scripts disabled will have links that work for them, but if scripts are enabled then it'll enable the AJAX loading.edit: nope, just realized that would totally break opening links in new tabs. You'd get a new tab with a
javascript:
URL that wouldn't do anything because theajax_load
function doesn't even exist in that new tab. If you wanted to reference an external function to do the AJAX loading, you'd have to make the Javascript URL first check that the function is defined, and if it isn't, fall back to settinglocation='...'
. Then the link should work if you open it in a new tab.another edit: you could create your
ajax_load
function as a property of thelocation
object, then change the link's action (e.g.http://example.com
) to:javascript:(location.ajax_load||location.replace).call(location,'http://example.com/');
Then if the javascript is executed in the context of your page, the
location.ajax_load
function will be called, but if it's not, it'll fall back to the nativelocation.replace
. Yourajax_load
function should, of course, check to see whether the URL is a local URL that should be loaded via AJAX (same origin) and do something sensible if it's not (open it in a new tab, probably).This still seems like a really horrible hack, but it might just be the best way to get AJAX navigation without reinventing the browser's native behavior as much as possible.
-
@Gąska why did you asymmetric DOS @anotherusername ?
-
@Gąska said in Alt-selecting links still opens them:
Works on everything except oneboxes, as far as I can tell.
Opening in a separate tab also does not work on mobile in App mode, except for iFramely.
Though with the recent update it has a slightly different URL...
-
@Gąska E_NO_REPRO.
On a completely unrelated note, here is a set of steps that will produce the effect you describe:- Hover over link.
- Hold down Alt.
- Press down left mouse button.
- Select part of the link.
- Release Alt.
- Release mouse button.
-
@pie_flavor Both his steps (release mouse button without releasing Alt) and yours (release Alt before releasing mouse button) cause the link to open in Firefox. The link is activated when the mouse button is released regardless of whether Alt is still pressed.
-
@anotherusername Huh. Well, only mine works in Chrome.
-
As stated, repro in Firefox but not Chrome.
-
@anotherusername said in Alt-selecting links still opens them:
There's no "activated" event
And that, ladies and gentlemen and attack helicopters, is TRWTF.
-
FWIW: E_NO_REPRO in Vivaldi, regardless of whether I let up Alt first or the mouse button first.
-
about:config
browser.altClickSave
Change it to false
Fuck you very much, Firefox.
-
@Lorne-Kates I think they changed it so false is the default.
That behavior definitely used to be enabled by default, though, because I've experienced it.
-
-
@anotherusername I have it at false, and I believe I've always had it at false, and I can reproduce the bug.
-
@Gąska Lorne's comment wasn't related to the original bug... his was about a different "feature" where clicking on a link with the Alt button pressed automatically downloads the link's target.
-
@anotherusername it was? It looked very much like a workaround instructions and complaining that Firefox is such a special snowflake it needs a workaround whereas all other browsers work just fine.
-
@Gąska Yes, it's something different.
Try enabling that option and see what happens then. Note that it's having absolutely no effect on WTDWTF, because the link-click action is completely overridden by Javascript here. You'll have to try it somewhere else to actually see the difference... it seems to take effect immediately, so you shouldn't need to restart the browser after toggling it.
-
@anotherusername I'm not talking about the setting in about:config. I'm talking about Lorne's post.
-
I'm using firefox and no repro here. that said, KDE uses alt+drag for moving windows, so FF is probably not even registering a click event.