我正在使用 Asp.Net/C#,我有一个要求,其中我想在提交数据之前显示确认,如果用户单击确定按钮,然后继续,或者取消提交。我知道 javascript 确认框会这样做,但是就我而言,我需要显示我自己的弹出窗口,任何人都可以建议我如何实现这一点。我不想在这里使用任何插件。感谢您的任何建议。
问问题
500 次
1 回答
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();
}
逻辑应该如下:我没有执行和测试只是看到逻辑忽略小错误如果有的话..还设置布局,边框看起来像确认窗口。
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
于 2012-06-07T10:01:06.960 回答