Home > Web Front-end > JS Tutorial > Summary of the method of opening a link in a new window implemented by JQuery_jquery

Summary of the method of opening a link in a new window implemented by JQuery_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:29:06
Original
1494 people have browsed it
First type: The following code is for the jb51 style. All a will open in a new window
Copy code The code is as follows:




Second:
Copy code The code is as follows:




In new window Open external link
Copy code The code is as follows:

$('a[href^=" http://"]')
.attr("target", "_blank");


Third type: If you want more convenient control
The XHTML 1.0 Strict version does not support the target="_blank" attribute, but using JQuery can solve this problem very well and open the web page in a new window:
Copy Code The code is as follows:

$('a[@rel$='external']').click(function(){
this.target = "_blank";
});

/*
Usage:

*/
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template