我有一个类似下面的代码,它在我的 chrome 浏览器中正确显示弹出消息,但我已经在其他浏览器(如 Firefox 和 Edge)上测试了它,这不起作用,它只是在页面的末尾...代码是:
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", 'data:text/plain,');
document.documentElement.appendChild(iframe);
if(window.frames[0].window.confirm("Are you sure you want to change brand state? Note: Changing brand state from Preview to Live will erase all data related to that brand.")) {
$.post("/brand/updateBrandState", {
'brandId': $(this).val(),
"brandState": $(this).find("option:selected").text()
}, function (data) {
if (data == "ok") {
window.location.reload(true);
}else if(data=="empty") {
alert("Cannot change state from Live to Preview");
window.location.reload(true);
}else if(data=="live") {
alert("Brand is now live!");
}
});
有人可以帮我让它在其他浏览器上也能工作吗??
谢谢!!
编辑:
现在我正在使用这个 html:
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
最佳答案
对于弹出框,使用jQuery Dialog .所有浏览器(支持 jquery)易于使用和支持。
演示
$("#myDialog").dialog({
resizable: false,
height: 140,
modal: true,
buttons: [
{
text: "Yes",
click: function () {
$(this).dialog("close");
//Do some Job
},
},
{
text: "No",
click: function () {
$(this).dialog("close");
},
}
],
open: function (event, ui) {
//add some functionality or styling if you want
},
//same for close,drag,dragStart,dragStop,focus and all
});
希望对您有所帮助。
关于javascript - 使用适用于所有浏览器的 jQuery 或 Javascript 创建弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37970175/