Showing
Picture with hyperlink to open link in a new window
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
$(document).ready(function(){
var
url = '://'
+ window.location.hostname;
// get the current website name, and i add
:// to make sure we're looking at the right name
// in the URL, rules out http://www.google.com/site:wss.domain.com
url = url.toLowerCase(); // lowercase
everything to compare apples to apples
$("a").each(function() {
var
link = this; // assign the link object to another
variable for easier managability
var
linkHref = link.href.toLowerCase(); // lower case
it
if(linkHref.indexOf(url) < 0 && linkHref.indexOf('javascript:')
< 0){
// check to see if this A object has this
domain in it and make sure it's not a javascript call
link.target = '_blank'; // change the target
to be in the new window
}
if(linkHref.indexOf('.pdf') > 0){ //
check to see if this is a PDF
link.target = '_blank'; // change the target
to be in the new window
$(link).removeAttr("onclick"); //remove
the SP click event
}
if(linkHref.indexOf('/forms/') > 0
&& linkHref.indexOf(').aspx') > 0){
//check for links in the forms library
link.target = '_blank'; // change the target
to be in the new window
$(link).removeAttr("onclick"); //remove
the SP click event
}
});
});
No comments:
Post a Comment