jquery trigger伪造a标签的click事件取代window.open方法
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>被点击
相关推荐
Chriswang 2020-04-30
donghongbz 2020-01-18
leonranri 2016-12-09
workflow 2013-08-15
stingfire 2012-05-16
itwxming 2015-09-02
周健华 2019-06-28
donghongbz 2011-10-12
去山中嘘嘘 2015-01-21
Awara 2019-06-27
小肖 2014-05-19
mxcsdn 2010-10-20
adeyi 2019-06-21
咸鱼 2012-10-28
greensomnuss 2012-10-09
Gcalolin 2019-06-20
愚盦 2011-05-24
每天积累一点点 2011-03-08
Lucianoesu 2018-10-27