One link to rule them all.
February 20, 2010 4:42 PM   Subscribe

I'm no web designer (I'll still make little pages with HTML/CSS if I have to, but that's about it). I have a web page, a reference page of sorts for friends and family, with links to other websites. Yes, it is very much like a page of bookmarks or favorites, but I update it fairly often.

I'd like to add at link at the top of the page that, when clicked, would open all of the other links on the page in new tabs. How would I do that? Javascript? Is that possible, am I missing something obvious? Thank you.
posted by Witty to Computers & Internet (5 answers total)
 
Can't speak to the JS end, but...

There are quite a few web browsers out there that can conveniently do this with either "Sessions" or "Bookmark Folders." Usually you can right-click on a bookmark folder and it'll have an option like, "spread em" or whatever, that spits out all the contents into new tabs. Opera also has a "Sessions" entry on the file menu.

I mention this because if you like the idea of having different sessions of tons of tabs (like work, hobbies, etc) it might be a pain to keep going back and using HTML/JS to update those when the browser's built-in tools will be faster.
posted by circular at 5:50 PM on February 20, 2010


You could easily do this in Javascript.

If I were feeling motivated I could probably do this in a few minutes with jQuery.

Basic approach:

- write a function that iterates through all the A elements in the page that have a particular class (you want to do this so you don't open your "open everything" link)
- - with each iteration
- - - open a new window (you can't tell your browser to open a new tab... you'll have to set up "open new windows in tabs" in your browser prefs)
- - - set the window location to be the URL of the link

- attach the function to the "click" handler of the "open everything" link.
posted by i_am_joe's_spleen at 6:06 PM on February 20, 2010


I'm a fan of linky for Firefox.

With it you'd highlight a bunch of links (maybe with control-a), right click, open selected in tabs.
posted by samsm at 7:11 PM on February 20, 2010


You can do this in Firefox with the addTab XUL method. Other browsers don't allow Javascript to open tabs.
posted by nicwolff at 7:32 PM on February 20, 2010


<script type="text/javascript">
function openLinks()
{
var aLinks = document.getElementsByTagName("a");
for (var i=0; i {
var a = aLinks[i].getAttribute("href");
if( a.indexOf('javascript:') == -1 )
window.open(a);
}
}
</script>

<a href="javascript:openLinks();" id="OpenMyLinks">Open Links</a>


Problem is, everytime you go to the page, all the links will open and not just the ones you just recently added.

posted by bbyboi at 7:34 PM on February 22, 2010


« Older Free computer help at a bar in Portland, OR?   |   Useful free software for a 12-year-old? Newer »
This thread is closed to new comments.