General :  K-Meleon Forum
General discussion about K-Meleon. 
Open all links in document in background
Posted by: ra
Date: September 18, 2004 09: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!

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

No one with an idea? ;-(

Options: ReplyQuote
Re: Open all links in document in background
Posted by: Rod
Date: October 05, 2004 10: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.

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: October 29, 2004 03:11AM

Still no one?

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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: jsnj
Date: October 29, 2004 03:27AM

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.

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: October 29, 2004 03:58AM

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.

Options: ReplyQuote
Re: Open all links in document in background
Posted by: jsnj
Date: October 29, 2004 04:38AM

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); } })();");
}


Options: ReplyQuote
Re: Open all links in document in background
Posted by: jsnj
Date: October 29, 2004 04:39AM

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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: jsnj
Date: October 29, 2004 04:44AM

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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: October 29, 2004 04:53AM

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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: October 29, 2004 05:31AM

Works like a charm, thanks again!

Options: ReplyQuote
Re: Open all links in document in background
Posted by: profiler
Date: November 20, 2004 09: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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: November 21, 2004 02:24AM

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.

Options: ReplyQuote
Re: Open all links in document in background
Posted by: Hao Jiang
Date: November 21, 2004 12:12PM

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

Hao

Options: ReplyQuote
Re: Open all links in document in background
Posted by: jsnj
Date: November 21, 2004 03:01PM

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

Options: ReplyQuote
Re: Open all links in document in background
Posted by: ra
Date: December 07, 2004 01:06AM

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?

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

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

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

Thank you, kko. Works!

Options: ReplyQuote


K-Meleon forum is powered by Phorum.