Open all links in document in background
Posted by: ra
Date: September 18, 2004 02:21PM

Hi!

I'm looking for a way to open all links from the current document in new background windows.

Is there already a macro for that or can anyone please help out in creating one?

Thank you!

Re: Open all links in document in background
Posted by: ra
Date: October 05, 2004 02:53PM

No one with an idea? ;-(

Re: Open all links in document in background
Posted by: Rod
Date: October 05, 2004 03:08PM

Idea: no., Lack of skills to make it possible: yes.
I really like the idea, so I'm also realy interested to hear from anyone who is more custom with creating macros.

Re: Open all links in document in background
Posted by: ra
Date: October 28, 2004 08:11PM

Still no one?

Is it at all possible to open several windows from a macro?

Re: Open all links in document in background
Posted by: jsnj
Date: October 28, 2004 08:27PM

I took a look at the request when you first posted it. There's a bookmarklet for opening all in foreground, but haven't found for opening in background. As you know, most bookmarklets can be converted to macros. But, without jscript there's no macro command AFAIK that can detect all links in a page. I only know of $LINKURL which gets the URL of the selected link.

Re: Open all links in document in background
Posted by: ra
Date: October 28, 2004 08:58PM

Thank you for looking into it and your reply!

Foreground would be a start I think. At least it is much better than nothing at all. :-)

It would be cool if you could post the code or link(s). Perhaps I'll eventually find the time to look into macros. Maybe there's the possibility to combine already existent code with new stuff. I just hope there'll be a way to get that one done.

Re: Open all links in document in background
Posted by: jsnj
Date: October 28, 2004 09:38PM

The following worked for opening links in the foreground when I tried it just now. Reference it in Accelerators or Menus with macros(OpenAllLinks)

OpenAllLinks{
getpref(BOOL, $popups) == "true" ? &PB2 : &AllLinks;
}
PB2{
&PBToggle; &AllLinks; &PBToggle;
}
AllLinks{
$macro = "OpenAll"; &JSEnable;
}
OpenAll{
open("javascriptsad smileyfunction(){var n_to_open,dl,dll,i; function linkIsSafe(u) { if (u.substr(0,7)=='mailto:') return false; if (u.substr(0,11)=='javascript:') return false; return true; } n_to_open = 0; dl = document.links; dll = dl.length; for(i = 0; i < dll; ++i) { if (linkIsSafe(dl.href)) ++n_to_open; } if (!n_to_open) alert ('no links'); else { if (confirm('Open ' + n_to_open + ' links in new windows?')) for (i = 0; i < dll; ++i) if (linkIsSafe(dl.href)) window.open(dl.href); } })();");
}


Re: Open all links in document in background
Posted by: jsnj
Date: October 28, 2004 09:39PM

Uh Oh...the forum didn't link the JS code.

Re: Open all links in document in background
Posted by: jsnj
Date: October 28, 2004 09:44PM

I've posted it into the wiki sandbox for now so you can copy & paste.

Re: Open all links in document in background
Posted by: ra
Date: October 28, 2004 09:53PM

Thank you, got the code. Will try it in a few minutes.

Re: Open all links in document in background
Posted by: ra
Date: October 28, 2004 10:31PM

Works like a charm, thanks again!

Re: Open all links in document in background
Posted by: profiler
Date: November 20, 2004 02:43PM

Hi ra!

Angus Turnbull published an
'Open in Background' Powertoy (5 August 2001)
jscript for IE context menu extension.

-------------- source:
var parentwin = external.menuArguments;
var cwn = parentwin.open('about:blank', '_blank', 'menubar=1,toolbar=1,location=1,scrollbars=1,resizable=1,status=1');
parentwin.focus();
cwn.blur();
cwn.location.href = parentwin.event.srcElement.href;
cwn.blur();
-----------------

The idea is to change the focus of the just opened new window by means of the
js blur() function and re-establish the focus on the originating window.
It works well for one new window at a time, maybe opening multiple windows will confuse the browser.
For use with k-meleon you would have to translate it into javascript.

try your luck

Re: Open all links in document in background
Posted by: ra
Date: November 20, 2004 07:24PM

Thank you very much for your answer, profiler! I will try to solve that one as soon as I find the time (might take some time...), although I don't know much about macros or javascript.

Re: Open all links in document in background
Posted by: Hao Jiang
Date: November 21, 2004 05:12AM

jsnj:
I tried your macros but it doesn't work here. Any trick?

Hao

Re: Open all links in document in background
Posted by: jsnj
Date: November 21, 2004 08:01AM

The forum broke the JS code. I've put it in the Macros Library.

Re: Open all links in document in background
Posted by: ra
Date: December 06, 2004 06:06PM

Okay, I'm still using the macro that jsnj posted, but noticed a problem:

It doesn't open more than 20 windows, no matter how many links are on the page, although I the prompt shows the correct amount of links.

Has anyone an idea what needs to be changed?

Re: Open all links in document in background
Posted by: kko
Date: February 08, 2006 12:37AM

You have to set a higher value for pref "dom.popup_maximum", it defaults to 20.

Re: Open all links in document in background
Posted by: ra
Date: February 27, 2006 12:56PM

Thank you, kko. Works!

K-Meleon forum is powered by Phorum.