jQuery加载新窗口

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代码

  
  

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

New 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

视觉工作室代码端到端针对Web开发人员的编辑和调试工具

Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers

远程工作的艺术

The Art of Working Remotely

表单设计模式

Form Design Patterns

From: https://www.sitepoint.com/jquery-load-window/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值