A way to open a set of links in new tabs automatically

S

spx2

Hi,

I'm writing on a project where I'd need to open a set of links on the
page automatically in new tabs.
So I don't want to change the target attribute of the link to open in
a new tab, but actually open the link
in a new tab.
I'll be using Opera and Firefox for the application.
Is there any way that I can make this work ?
I see in previous versions it was possible to generate an click event
and dispatch it to the link,
but not sure if this is still possible with current implementations of
Firefox due to security concerns ?
I'm really looking forward to your oppinions on this
 
E

Evertjan.

spx2 wrote on 20 sep 2009 in comp.lang.javascript:
I'm writing on a project where I'd need to open a set of links on the
page automatically in new tabs.

The choice between tabs and new pages is not accessable from the page's
script in most if not all tab-ready browsers.
So I don't want to change the target attribute of the link to open in
a new tab,
but actually open the link in a new tab.

=======================================
var theURL = '/myFolder/myUrlNr';
var numberOfUrls = 17; // myUrlNr0 to myUrlNr16
for (i=0;i<numberOfUrls;i++)
window.open(theUrl+i+'.html','_blank');
=======================================

They could open in new windows, if the browser is not set to open in tabs.
I'll be using Opera and Firefox for the application.
Is there any way that I can make this work ?

Please make yourself more clear.
I see in previous versions it was possible to generate an click event
and dispatch it to the link,

You cannot "dispatch [something] to [a] link"
Ah, you mean dispath it to the other tabs/windows?
If they are in the sme domain, you can:

=======================================
var theURL = '/myFolder/myUrlNr';
var numberOfUrls = 17; // myUrlNr0 to myUrlNr16
for (i=0;i<numberOfUrls;i++)
window.open(theUrl+i+'.html','windoNr'+i);

....

<span onclick =
windoNr5.document.getElementById('div1').innerHTML = 'foo said:
click Me</span>

=======================================

not tested!
but not sure if this is still possible with current implementations of
Firefox due to security concerns ?

Crossdomain security reasons,
leaving someone's concerns for what they are.
I'm really looking forward to your oppinions on this

It would be too bad if you couldn't care less. ;-)

[please use a name or nickname and a signature]
 
T

Thomas 'PointedEars' Lahn

spx2 said:
I'm writing on a project where I'd need to open a set of links on the
page automatically in new tabs.

I don't think you need that.
So I don't want to change the target attribute of the link to open in
a new tab, but actually open the link
in a new tab.

What about users with clients without client-side script support?
I'll be using Opera and Firefox for the application.

Which versions on which operating systems?
Is there any way that I can make this work ?
I see in previous versions it was possible to generate an click event
and dispatch it to the link,

Really? How?
but not sure if this is still possible with current implementations of
Firefox due to security concerns ?

You mean _versions_, not implementations. And why don't you simply try the
solution that once worked with the newer versions?
I'm really looking forward to your oppinions on this

<http://jibbering.com/faq/#posting>
<http://www.catb.org/~esr/faqs/smart-questions.html>


PointedEars
 
E

Evertjan.

Hans-Georg Michna wrote on 20 sep 2009 in comp.lang.javascript:
Usually triggers a popup warning dialog on newer browsers,
unfortunately.

No it does not "usually", it depends on the settings,
and on the ideas of the browser programmers.

I don't have set such constraints.


So it is not open to the general public, [they use IE, even IE6 and Chrome
and Safari too, remember] so he can tell the users to set the browser
othrerwize.

No, there is no way you can circumvent my browser settings,
and that is a good thing.
I've been looking for a solution to this as well,

Most of us here are happy and know that such looking is useless.
just on my own
computer. Currently use an AutoIt script, which is a rather
crude method.

I doubt that it would work on most browsers over which you have
no control, because of the popup blockers. It would be a
spammer's dream if this worked. They'd love to fill your tabs
with their garbage.

Indeed, but the OQ suggests a controlled browser environment.
 
S

Stefan Petrea

spx2 wrote on 20 sep 2009 in comp.lang.javascript:
I'm writing on a project where I'd need to open a set of links on the
page automatically in new tabs.

The choice between tabs and new pages is not accessable from the page's
script in most if not all tab-ready browsers.
So I don't want to change the target attribute of the link to open in
a new tab,
but actually open the link in a new tab.

=======================================
var theURL = '/myFolder/myUrlNr';
var numberOfUrls = 17; // myUrlNr0 to myUrlNr16
for (i=0;i<numberOfUrls;i++)
   window.open(theUrl+i+'.html','_blank');
=======================================

They could open in new windows, if the browser is not set to open in tabs..
I'll be using Opera and Firefox for the application.
Is there any way that I can make this work ?

Please make yourself more clear.
I see in previous versions it was possible to generate an click event
and dispatch it to the link,

You cannot "dispatch [something] to [a] link"
Ah, you mean dispath it to the other tabs/windows?
If they are in the sme domain, you can:

=======================================
var theURL = '/myFolder/myUrlNr';
var numberOfUrls = 17; // myUrlNr0 to myUrlNr16
for (i=0;i<numberOfUrls;i++)
   window.open(theUrl+i+'.html','windoNr'+i);

...

<span onclick =
windoNr5.document.getElementById('div1').innerHTML = 'foo said:
click Me</span>

=======================================

not tested!
but not sure if this is still possible with current implementations of
Firefox due to security concerns ?

Crossdomain security reasons,
leaving someone's concerns for what they are.
I'm really looking forward to your oppinions on this

It would be too bad if you couldn't care less. ;-)

[please use a name or nickname and a signature]

Ok, so thanks a lot for taking the time to write this :)
I've used the second piece of code , and I'm opening up some links
and saving the returned Window reference objects in openedWindows
(in order to know what to close from the close_links_new_tabs button
later).
Also, after opening the windows up I'd like to re-focuse on the
initial window.
And I'm doing window.focus() , and it doesn't work.
I've checked that was the real window I wanted by trying to see the
title of the window.
So it's a bit weird that the last opened window is focused and at the
same time,
when I print window.document.title what I see is the title on which
the open_links_new_tabs
button was...
I've also tried to store the window object before the .each call
(which is actually a for loop)
and apply .focus to that and it still does not focus.

289 $("#open_links_new_tabs").click(function(){
290 // opens the links in the items in new
tabs
291 var i = 0;
292 $(".table_row > td > a").each(function() {
293 i++;
294 openedWindows.push(
295 window.open($(this).attr
('href'),'opened_link'+i)
296 );
297 //alert($(this).html());
298 });
299 window.focus();
300 });
301
302 $("#close_links_new_tabs").click(function(){
303 $(openedWindows).each(function(idx,obj)
{ obj.close() });
304 });

Maybe you have a suggestion related to this ?

Thanks,
Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top