我正在使用Asp.Net/C#,我有一个要求,我想在提交数据前显示确认,如果用户点击OK按钮,然后继续,或者取消提交。我知道javascript确认框确实这个,但在我的情况下,我需要显示我自己的弹出窗口,任何人都可以建议我如何实现这一点。我不想在这里使用任何插件。 感谢您的任何建议。
答案 0 :(得分:1)
您可以创建如下:
function createPopup() {
//Get the data from the form fields
var background = document.custom.back.value;
var title = document.custom.title.value;
var text = document.custom.text.value;
//Now create the HTML code that is required to make the popup
var content = "<html><head><title>"+title+"</title></head>\
<body bgcolor='"+background+"'><h1>"+title+"</h1>"+text+"<br />\
<a href='javascript:window.close()'>Close the popup</a></body></html>";
//Create the popup
var popup = window.open("","window","resizeable,width=400,height=300");
popup.document.write(content); //Write content into it.
pops.document.close();
}
逻辑应该如下:我没有执行和测试只是看到逻辑忽略minore错误,如果有..也设置布局,边框看起来像确认窗口。
function popup() {
alert('popup called');
//Now create the HTML code that is required to make the popup
var content = "<html><head><title>ConfirmBox</title></head><body >Do you want to continue ? <br />
<input type='button' value='ok' onclick='return true'/>
<input type='button' value='cancel' onclick='return false'/> <a href='javascript:window.close()'>Close the popup</a></body></html>";
//Create the popup
var popup = window.open("","window","resizeable,width=400,height=300");
popup.document.write(content); //Write content into it.
pops.document.close();
}
参考http://www.openjs.com/tutorials/advanced_tutorial/popup.php