我似乎搞不懂这件事。单击该按钮后,它将打开一个对话框以确认是否要继续“转到此链接”(即google.com)。如果是的话,它应该会指引你找到链接。但是,我找不到一个办法来解决这个问题。我有两个有不同链接的按钮。
查看jsfiddle 这里
HTML:
<button class="open" onclick="window.open('http://google.com')">Google</button>
<button class="open" onclick="window.open('http://yahoo.com')">Yahoo</button>
<div class="unique">Are you sure you want to continue?</div>联署材料:
$(function() {
$('.open').on("click", function(e) {
var link = this;
e.preventDefault();
$('.unique').dialog({
buttons: {
"Ok": function() {
window.location = link.href;
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
});CSS:
.unique {display: none;}但是如果我使用下面的(http://jsfiddle.net/mJwMu/) --它工作得很好。然而,我只能直接到一个环节。这不是事实-我希望能够直接到多个链接。(Google.com/yahoo.com/msn.com/等等)
HTML:
<button class="open">Google</button>
<div class="unique">Are you sure you want to continue?</div>JS:
$(function() {
$('.open').on("click", function(e) {
var link = this;
e.preventDefault();
$('.unique').dialog({
buttons: {
"Ok": function() {
window.open('http://google.com');
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
});CSS:
.unique {显示:无;}
感谢你的帮助!
发布于 2013-05-22 13:52:41
HTML
<button class="open" data-href="http://www.google.com">Google</button>
<button class="open" data-href="http://www.yahoo.com">Yahoo</button>
<div class="unique">Are you sure you want to continue?</div>jQuery
$(function () {
$('.open').on("click", function (e) {
var link = this;
e.preventDefault();
$('.unique').dialog({
buttons: {
"Ok": function () {
window.open($(link).attr("data-href"));
$(this).dialog("close");
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
});
});https://stackoverflow.com/questions/16693480
复制相似问题