jQuery代码段可在新窗口中加载/打开链接。 此代码将事件添加到指定了“ new-window”类的锚标记,并强制它们在新窗口中打开。
$(function(){
$('a.new-window').click(function(){
window.open(this.href);
return false;
});
});
进阶jQuery载入新视窗范例
此代码获取容器div的ID,然后获取隐藏的url div元素,然后在新窗口中将其打开。
function openblog(blog_id) {
//alert(blog_id);
$('#blog-wrap-'+blog_id).hide();
var blogurl = $('#'+blog_id+'-url').text();
var location = "http://domainname/index.php?blogurl="+blogurl;
window.open(location);
}
HTML代码
http://blogoola.comNew books out now!
💁♀️ Fun Fact: Python was ranked #2 on a recent highest paid coders list. *
🤓 Ok. When did a code editor from Microsoft become kinda cool!?
Popular Books
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers
The Art of Working Remotely
Form Design Patterns