Please make middle-clicking on javascript "open new window" links work!

Forums » Opera for Windows/Mac/Linux » Desktop wish-list

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

26. January 2007, 19:46:37

Please make middle-clicking on javascript "open new window" links work!

The middle-click open in background function is a fantastic feature I use all the time, but the links that, when you hover the mouse over them, say "Address: javascript: ol('http://www.anadress.com')", always open a blank tab on middle click. Any chance of making this work?

EDIT: While I'm on the subject, how about making it work on the bookmarks menu too? But maybe that's a windows limitation, I don't know.

Also, can you make image captions/alt-text visible on image tooltips, as in IE, in addition to the actually useful address information Opera usually gives? Or is there a setting for this I've not found yet?

27. January 2007, 01:39:04

hermen2048

Posts: 1234

Originally posted by YourMessageHere:

The middle-click open in background function is a fantastic feature I use all the time, but the links that, when you hover the mouse over them, say "Address: javascript:ol('http://www.anadress.com')", always open a blank tab on middle click. Any chance of making this work?



+1. I use an user CSS file to `mark' javascript links on hover with an orange border:

a:hover[href^=javascript], a:hover[onclick] {
	outline: 2px solid #F80;
}


Originally posted by YourMessageHere:

Also, can you make image captions/alt-text visible on image tooltips, as in IE, in addition to the actually useful address information Opera usually gives? Or is there a setting for this I've not found yet?



The following UserJS ( about this feature: http://www.opera.com/support/tutorials/userjs/ ) will add a title attribute with the same value as the alt attribute to every image:

http://scripts.userjs.org/browser/enhancements/add-alt-text.js
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

27. January 2007, 02:23:11

Cool, thanks. Nonetheless it'd be nice to see as a built-in option (especially as it's clearly simple to do if you have some idea what you're doing with Java).

27. January 2007, 13:22:14

serious

Lab mouse and likes it!

Posts: 5297

big +1 from me. I hate javascript links, that don't work when opened in new tab.
All my posts only represent my own opinions.
[ Tweedo Monitor - Deluxe Website & Service Monitoring ]

27. January 2007, 14:43:37

Moderator

Tamil

:-(|)

Posts: 115306

Originally posted by hermen2048:

I use an user CSS file to `mark' javascript links on hover with an orange border

See http://userjs.org/scripts/browser/enhancements/link-alert

28. January 2007, 07:56:09

d4n3

Posts: 957

Originally posted by YourMessageHere:

Cool, thanks. Nonetheless it'd be nice to see as a built-in option (especially as it's clearly simple to do if you have some idea what you're doing with Java).


It's not as simple as it would seem. There isn't only one way to open links with javascript and implementations differ from site to site. Typically it's a call to a custom procedure named for example openPopup() which calls the appropriate procedure to open a popup window with specified parameters.

The problem is, the method could be relying on some variable or call another method declared in the scope of the current page. Therefore, you would have to have the entire scope of the current page present for the method to execute properly.

Executing openPopup() in a new (blank) tab will obviously not work because it wasn't declared there. But, for it to work, the entire page where the function is called from would have to be loaded in this tab for it to work properly. So it would have to do something like duplicate the tab then execute the javascript (which would open another new tab).

But, since there are some links with javascript in them which do not open popup windows but do other stuff, just duplicating the current tab would probably have some negative consequences...

So I don't think it's that trivial a matter.



But writing such links is just bad practice as it obviously breaks navigation. (Think for example users who disable javascript or browing on mobile devices). This is something web authors would have to correct. There is a proper way of opening such popup windows - using graceful degradation.

It's actually very simple - you create a link pointing to the page you want to display in a custom popup. Then, you give that link an event onclick="javascript:pop();return false;" The pop() method will open the link in a popup window with javascript and the return false will "consume" the click so the browser will not open the link like it would normally. But, if you middle-click on the link, the browser will follow the link specified in the HREF variable, so it will open the link in a new blank tab.

You actually can see an example of this the opera front page: www.opera.com
Try left clicking on the picture of the mobile phone. It opens an AJAX popup window.

Now middle click it - it opens a page in a new tab!


PS: Also, it's Javascript, not Java. These are two completely different things with a misguidingly similar name.

28. January 2007, 09:14:08

profiT

Posts: 453

+1

Of course, i would like to see this feature. But i can't even imagine how it can be implemented...
selection2rtf.js -- exporting selection to Word files (with images and some formatting)
Convert2PHF.js -- saving in single htm or mht file

29. January 2007, 23:29:53

shoust

Operaised

Posts: 3196

I've made this userjs in attempt to make it that these sorts of links work smile (In most cases at least)

Enjoy smile

makesomemiddleclickwork.js
My Opera I burning the E
Thats the way it should always B.
smile

16. March 2007, 10:59:56

drlaunch

Traveler from Beyond

Posts: 1063

Looks like it could be a great script. But it doesn't work on http://oc.ormgas.com/search.php .

A possible fix would be to make JS links open the same page in another window and immediately execute the JS you middle clicked there. But I'm not sure if that's possible.

16. March 2007, 20:10:03

CsendesMark

Opera user :)

Posts: 416

yes I agree!+1
Opera maniac

16. March 2007, 22:15:36

Zajec

Posts: 4008

If it is possile and problem less: +1. I cannot really understand d4n3's post (cause on english).
My software:
Opera 11.51 [1087] ; openSUSE 11.4

My wishes:
* HTML5: Drag and drop
* HTML5: History

8. April 2007, 06:50:00

tjthe1st

Posts: 17

+1

and another +1 for the bookmarks opening in a new tab.

10. April 2007, 16:20:58

seifip

Flasher

Posts: 793

+1
design is like a puzzle. I`m just trying to solve it now...

+ Opera Lover Survival Kit - full of banners, avatars, userbars & other crap nobody can live without smile
+ Restaurant at the end of the universe - The Hitchhiker's Guide to the Galaxy movie petition
+ Best Opera widgets ever! - Exclusive design, first class usability, minimal CPU usage

Support the quest for 64-bit Opera

5. June 2007, 20:39:27

SuperKoko

Posts: 725

Handling JavaScript/ECMAScript links as true links is a feature I wish very much.
I wanted to submit a proposal, and discovered that this had been already been requested!

Originally posted by profiT:



Of course, i would like to see this feature. But i can't even imagine how it can be implemented...


Many, but not all, JavaScript links, can be detected by simple pattern matching.

Things such as:
<a href="javascript:window.location='http://domain-name/http-get-param'">Link</a>
Or variations:

window.open('link')
OpenUrl('link')
window.location.replace('link')


Blocks having a onclick event would be seeked as "JavaScript links" too.

Unfortunately, it would be far more complex to handle JavaScripts that call a user-defined function, even for dumb functions such as:
function popup(link) {
  window.open(link);
}

Because the function may be modified by another script executed somewhere in the page.
popup=function(link) {} // Replace the function by a function doing nothing.


At best, it might be possible to detect a JavaScript link by exploring the JavaScript namespace at the time the link is "used": Right-clicked or middle-clicked or the tooltip is ready to display when hovering it.
Predicting whether a JavaScript function is a dumb linking function will, of course, not always work.
Only links matching specific patterns would be detected.

Now here is how I wish that these links be treated:
I would like that they be treated as much as normal anchors as possible but there would be a special indication that these are not normal links when the tooltip is displayed when hovering the mouse on the link. Among other things, it would indicate the behavior of the JavaScript: For example "popup" or "open in current window".
Moreover, opening them (e.g. by clicking on them) would, by default, produce the same behavior than the JavaScript is supposed to do. For example, for a "popup" JavaScript, it would open the new page in a popup window.
But, for any other thing, they would behave as normal links:
  • The usual tooltip "Address:<URL>" would be displayed when the user hover the cursor on them.
  • Middle click and other user shortcuts would work as for normal links.
  • Right clicking on them would popup the usual menu, with the usual options:
    • Open
    • Open in new tab
    • Open in background tab
    • Open in new window
    • Open in background window
    • Bookmark link
    • Copy link address
    • Save target as...
    • Save to download folder

    [*] The "search in links" feature of Opera would search into them.
    [*] Future features of Opera would treat them as normal links.
    [/list]

    I request an additionnal feature: An option "Open in current window" would be added to the menu of links. This would override the default behavior of opening popup JavaScripts into popups...
    There would be a user configurable shortcut to this option. The default would be CTRL+CLICK or anything easy to use.
    It would even be possible to configure the default behavior of mouse left click to be "Open in current window".
    This feature would also work for links having a target attribute.

    I know that detecting JavaScript links would be difficult and that many of them would not be detected.
    But I'm sure that many of these awful JavaScript things can be detected and transformed into true links.

    6. June 2007, 02:57:07

    Turin

    Posts: 1279

    I agree with first wish. Even if Opera could not load more exotic Javascript cases with middle click functionality, at least catching the most common form of Javascript links would be a welcome improvement.
    Proud member of the Opera 9.27 userbase. Windows Linux Macintosh Solaris FreeBSD

    26. July 2007, 15:55:15

    GeeZuS

    Posts: 219

    +99

    it is a pain in the ass not to have this feature.
    imagine accepting the truth

    27. July 2007, 03:33:36

    ViperAFK

    Posts: 332

    +100 can't stand this

    24. March 2008, 02:41:35

    +1
    Opera 10.10 | Ubuntu 9.10 | Windows 7

    24. March 2008, 19:50:44

    alf5000

    Posts: 393

    +1
    would make surfing the web MUCH more comfortable
    Win7Professional x64 (incl. latest updates) - Intel i5 - 4GB RAM - internal Intel HD Graphics

    25. March 2008, 04:50:44

    dude09

    ex-Opera user

    Posts: 5195

    +1 This is another annoying behavior like the auto-scroll... please changed it ASAP.

    27. March 2008, 23:12:21

    daroc

    Posts: 4810

    +1
    But... how?
    Maybe we should vote +1 for: make webmasters publish valid and open webpages?

    Forums » Opera for Windows/Mac/Linux » Desktop wish-list