perfected text-URL pagelaunch
Wednesday, July 23, 2008 12:45:54 PM
(2010-3-25: in 10.5, open-in-backgournd not usable due to this bug)
(green links are button-installer tags)
If you rightclick in selected rendered text, the context menu that pops up seems to give you only one launch option: Go to web address. In fact, you can add Shift as you select it to ensure that the page launches in a new window; or Shift +Ctrl, to make it launch in the background - but you have to be aware of those rules, and willing to use both hands. And if the link is in editable text, you're out of luck and will have to copy and paste.
It would be nice to have those launches on the menu, where they are obvious and generable with a simple click, and to cope with editable text. One can write macros - strings of Opera functions - which do this. But they have their own flaws which, though minor, are real: they erase the clipboard, and either mess up tiling, or depend on using, and sticking to, non-standard settings.
Javascript makes flawless functions (which can go on menu, keystroke, gesture or toolbar) possible; here they are. The old macro versions are also included - in case anyone keeps javascript off, and to show how complicated things get when one must allow for preference settings.
Colours used to mark components: menu format, menu label, action, icon.
Add to both Hotclick Popup and Edit Widget Popup menus:
Item, "Go, new"= Go to page, "javascript: var url=(document.getSelection()); if (url.indexOf('http://%27)==-1) {var url=('http://%27+url)}; window.open(url)();void(0)",,,"forward"
Item, "Launch, BG"= Go to Page, "javascript: var url=(document.getSelection()); if (url.indexOf('http://%27)==-1) {var url=('http://%27+url)}; window.open(url).blur();",,,"open link"
as buttons:Go, new , Launch, BG
keystrokes or mouse gestures: use only the red - paste into customization dialogue.
And, so you can try it out: www.zombo.com
notes
- background version requires this preference to be checked: Allow script to lower window
- checks for http:// in the selection, adds if missing - address otherwise interpreted as relative.
- Shift=new, Shift+Ctrl=background convention (by the way) also works for searches selected from a menu, and for address-field launches and searches.
- to open a set of text links in the background from a list, TexToTabs button (from forum members Nothing Special and Shoust, in this thread) works.
- there is an Opera function which sounds like it should work: Open URL in new background page. Alas, it doesn't accept variables - it's only usable with URLs explicitly typed in as part of the command.
historical interest: doing it with macros
Here's what it takes to provide the functions via macros (i.e. using Opera functions and not javascript). The Go To Page command is used, with two variables. %t stands for selected text; %c is clipboard content, and requires a prior Copy. It's better not to use the clipboard if you don't have to, to avoid erasing what you may have in there. But everyone has to use Copy&Go for selections in editable text, which %t misses; and those who use the Reuse current tab setting have to use it for the other launches as well (because they must issue a New Page command before the launch, which takes things to a page where there is no selection for %t to capture - so Copy must be invoked before this happens). Other preferences (see Note 1) affect what function should be used to get back to the starting page (which is how background launch is effected), making a rather complicated situation: two New Page variants, and four Background variants.
%t launches (for rendered text, for those who keep Reuse current tab off):
Launch in new window:
the function already on the Hotclick Popup menu works; here it is with an icon:
Item, "Launch"= Go to page, "%t",,,"forward"
Launch in background variants:
Item, "Launch in BG"= Go to page, "%t",,,"open link" & minimize page
Item, "Launch in BG"= Go to page, "%t",,,"open link" & switch to previous page
buttons: Launch; Launch,BG (using Minimize)
Copy&Go (editable text for everyone; rendered too, for those who keep Reuse current tab on):
Launch in new window:
Item, "Copy+Go, New"= Copy,,,,"forward" & New page & Go to page, "%c"
Launch in background variants:
Item, "Copy+Go, BG"= Copy,,,,"open link" & New page & Go to page, "%c" & minimize page
Item, "Copy+Go, BG"= Copy,,,,"open link" & New page & Go to page, "%c" & switch to previous page
buttons: Copy&Go; Copy&Go,BG (using Minimize)
menu setup for macro versions
rendered text: add (1 or 2) functions appropriate to your prefs to Hotclick Popup Menu
editable text: add (1 or 2) Copy&Go functions (if BG, appropriate to prefs) to Edit Widget Popup menu
notes on macro versions
- Minimize variant needed if one keeps Open New Tab Next to Active unchecked; Switch variant better if one keeps Open New Tab Next to Active checked and sometimes use tiling. (Sometimes answers can't be simple, because the system is complex. What command will get you back to the tab you launched from? Switch To Previous Page works, if you use the Open New Tab Next to Active setting. However, if you don't, it's not right: you may jump several tabs right to open the new one, but only come back one. Cycle To Previous Page would handle that - but fails unless you use Cycle without showing list. Minimize Page gets around both of those - but minimized panes are excluded from tiling. So a user who sometimes tiles and always uses Open New Tab Next to Active is better off with Switch To Previous (I'm in that group). Which said - what do you post as a button? If macros had access to settings and branching, you could make a button that checked settings and picked the right function. As it is, there must be variants.)
- the New Page in the Copy&Go macros is superfluous for tab non-reusers, but does no harm: it does not result in an extra empty tab.
relevant background lore:
- icons are fourth parameter: come after fourth comma. If you don't specify an icon, you'll get the default icon for the command, if it has one. To suppress it, specify "no icon" as fourth parameter. Normally, the icon for the first function will be used, and others have no effect - but there is a quirk, operating here (in toolbars but not in menus), whereby the icons of initial Copy commands are ignored if no text was selected when the page was focused (the icon from the second function is used). To make chosen icons show consistently, icons are assigned to initial Copy and to second function as well.)
- ampersand in menu label causes next character to be selector.






