jQuery在新窗口中打开外部链接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery在新窗口中打开外部链接相关的知识,希望对你有一定的参考价值。
Two different ways to open an external link (ones that start in http) in a new window. I know this isn't a great thing to do, but some clients _need_ to have it.
//Grab the href, open it in a window and cancel the click action $("a[href^='http']").click(function(){window.open(this.href); return false;}); //Add target = blant to the external link $("a[href^='http']").attr('target','_blank'); //Similar to the first, only using your domain name $("a:not([href*='yourdomainnamehere.com'])").click(function(){ window.open(this.href); return false; }).attr("title", "Opens in a new window");
以上是关于jQuery在新窗口中打开外部链接的主要内容,如果未能解决你的问题,请参考以下文章