$("[EMAIL PROTECTED], [EMAIL PROTECTED] ...").attr("_target", "blank")
or
$("[EMAIL PROTECTED], [EMAIL PROTECTED] ...").click(function() { window.open(
this.href) })
On 1/8/07, agent2026 <[EMAIL PROTECTED]> wrote:
Back from the holidays, and back to my problem :)
In short:
I want to go through all links on a page and, barring my array of
exceptions, make all external links open in new windows without using the
target attribute. In addition, the exception urls must be able to just
contain the exception strings (using something like .match) and not have
to
be an exact match. In other words any urls within those domains will be
exceptions.
The
http://www.nabble.com/Change-href-of-external-links-tf2718387.html#a7579373
previous thread I started got a lot of help, but required an exact match
and started to go a bit over my head. So I've started fresh:
$(function(){
var a = ($('a'));
var intLink = ['
mysite.com/','site1.com/','site2.com/','site3.com/']; //
treat as internal
for(i=0;i<a.length;i++){
for(n=0;n<intLink.length;n++){
var nLink = intLink[n];
if(!a[i].href.match(nLink)){ // treat as external
//console.log(a[i].href);
$(a[i]).bind('click', function(){
window.open(this.href); return false;
});
}
};
};
});
I've put all domains to be treated as internal in the var intLink,
including
the current domain (the site itself). Things look pretty good in Firefox
-
all the .binds appear to be successful - but the console doesn't always
log
all the links on the page that should be treated as external even thought
the .bind works, so that's a little worrying.
In IE6/7 I've got all kinds of weirdness happening, and seem to be getting
nowhere. Appreciate it very much if anyone can have a look, or can think
of
a better way.
Adam
--
View this message in context:
http://www.nabble.com/IE-woes-%28was-Exteranl-Links%29-tf2940328.html#a8221227
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
--
Yehuda Katz
Web Developer | Wycats Designs
(ph) 718.877.1325
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/