Feb20
using js to open links in current window, new window, or in the background
Posted by: Brian Chan | Filed in: technology | Tags: programming | 05:17 pm, February 20th, 2012 Add comments
There are times to open links in the current window, sometimes in a new window, sometimes in background. Here is how to do it.
1 2 3 4 5 6 7 8 | function open2(url, opt){
if (opt == 0) // current window
window.location = url;
else if (opt == 1) // new window
window.open(url);
else if (opt == 2) // background window
{window.open(url); self.focus();}
} |
The syntax is a bit confusing, I guess these should be standardized in the future.
Ref link: http://snippets.dzone.com/posts/show/2915
Related posts: