jquery trigger伪造a标签的click事件取代window.open方法

时间:2014-06-23    点击:111   
var ohtml='<div class="friend-dialog tac pt15 pb20">'+ 
'<div class="f-h32">您已经成功发送好友申请。</div>'+ 
' <p class="c999">上传真实头像,好友申请更容易被通过哦,赶紧上传头像吧!</p> '+ 
'<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a>'+ 
' </div>'; 
$.dialog({ 
lock:true, 
title: '温馨提示', 
button: [ 
{value: '点击上传图像',callback: function () { 
$("#awindowopen").trigger("click"); 
},focus: true 
} 
], 
content:ohtml 
}); 
var ohtml='<div class="friend-dialog tac pt15 pb20">'+
'<div class="f-h32">您已经成功发送好友申请。</div>'+
' <p class="c999">上传真实头像,好友申请更容易被通过哦,赶紧上传头像吧!</p> '+
'<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a>'+
' </div>';
$.dialog({
lock:true,
title: '温馨提示',
button: [
{value: '点击上传图像',callback: function () {
$("#awindowopen").trigger("click");
},focus: true
}
],
content:ohtml
}); 


需要注意的是:

在这个地方:

<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a> 
<a href="<%=path%>/teacher/editUserAvatar.action" target="_blank"><span id="awindowopen" ></span></a>
<a>标签内一定要有内容,并且要模拟里面的内容被点击而不是<a></a>被点击
IE8中使用javascript动态加载CSS的解决方法
jQuery循环滚动新闻列表示例代码
页面刷新时记住滚动条的位置jquery代码
jquery 为a标签绑定click事件示例代码
a标签click和href执行顺序探讨
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved