I’m looking at creating a list of links that when each one is clicked, opens a new window/tab under the current window, the reason for this is that i’m using jQuery .toggle to switch content upon click of a link to reveal a message. They have to read this message before going to the new window, which is why it must be opened below the current window (Hope all that makes sense!).
I’ve got the content switching part done, which is great, but having some trouble coding the “New Window opening under the current window”
Thw following code (When used with jQuery) opens up a new window under the current window (Yay!) - BUT - this happens on page load (Arghhhh) - so I’m wondering if any jQuery guru’s out there can help me take this working functionality and simply apply it to the links, and only apply it to link with a certain class e.g. class=“newwindow”
$(document).ready(function() {
var link = $(this).attr('href');
var mer_window = window.open(link, '_blank', 'toolbar=1,location=1,directories=1,scrollbars=1,resizable=1,status=1,menubar=1');
if (typeof mer_window === "object")
{
mer_window.blur();
}
return false;
});
As potentially there could be 1000’s of links, it has to be portable, so can’t literally hard code the physical links within the JS.
Wow, that worked perfectly, it now only happens when a link is clicked!!
I’ve noticed just one thing now, instead of it opening the link e.g. sitepoint.com - it infact opens a page with “undefined” in the address bar… so we are half way there!
Perhaps it’s something to do with how the link is defined?
var mer_window = window.open(link, '_blank','toolbar=1,location=1,directories=1,scrollbars=1,resizable=1,status=1,menubar=1');
var link = $(this).attr('href');
??
Though i’m not sure myself, any ideas here please?