1. The standard method
Copy Code code as follows:
<script type= "Text/javascript" >
function Openwin (src, width, height, showscroll) {
window.showModalDialog (SRC, "", "Location:no;status:no;help:no;dialogwidth:" +width+ ";d ialogheight:" +height+ "; Scroll: "+showscroll+"; ");
}
</script>
Example: <span style= "Cursor:pointer" onclick= "Openwin
(' http://www.jb51.net ', ' 500px ', ' 400px ', ' no ') ' > click </span>
2. It is to be noted that Firefox does not support this feature, it supports the syntax is
window.open
(' openwin.html ', ' newwin ', ' Modal=yes, Width=200,height=200,resizable=no, Scrollbars=no ');
3. How to automatically judge the browser
Copy Code code as follows:
<input type= button value= Open dialog box "onclick=" ShowDialog (' # ')/>
<script language= "JavaScript" >
<!--
function ShowDialog (URL)
{
if (document.all)//ie
{
Feature= "Dialogwidth:300px;dialogheight:200px;status:no;help:no";
window.showModalDialog (url,null,feature);
}
Else
{
Modelessdialog can replace modal with Dialog=yes
Feature = "Width=300,height=200,menubar=no,toolbar=no,location=no,";
feature+= "Scrollbars=no,status=no,modal=yes";
window.open (url,null,feature);
}
}
-->
</SCRIPT>
4. In IE, the modal dialog box hides the Address bar, while in other browsers it is not necessarily
"Note" In Google Browser, the effect of this mode will also be ineffective.
5. Generally in the pop-up dialog box, we all want the background of the entire parent page to become a translucent color, so that users can see the following is not accessible
When you close the dialog box and then you want to restore
How did this happen?
Copy Code code as follows:
Displays the details of an order through a modal dialog box, and the screen changes color
function Showorderdetails (orderId) {
var url = "details.aspx?orderid=" + OrderID;
$ ("Body"). CSS ("filter", "Alpha (opacity=20)");
Filter:alpha (OPACITY=50)
$ ("Body"). AddClass ("body1");
Showdetailsdialog (URL, "600px", "400px", "yes");
$ ("Body"). Removeclass ("body1");
}
In addition, there is a style sheet definition
. body1
{
Background-color: #999999;
Filter:alpha (OPACITY=40);
}
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "WebForm1.aspx.cs" inherits= "Webapplication1.webform1"% >
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
< Title></title>
<style type= "text/css"
body1{
Background-color: #999999;
Filter:alpha (opacity=40);
}
</style>
<script src= "jquery.js" type= "Text/javascript" > </script>
<script type= "Text/javascript"
function Showdetailsdialog (src, width, height, showscroll) {
window.showmodaldialog (SRC, "", "Location:no;status:no;help:no;dialogwidth:" + width + ";d ialogheight:" + height + "; scroll" + Showscroll + ";");
}
function Showorderdetails (orderId) {
var url = ' details.aspx?orderid= ' + OrderID;
$ ("Body"). AddClass ("body1");
Showdetailsdialog (URL, ' 500px ', ' 400px ', ' no ');
$ ("Body"). Removeclass ("body1");
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<span style= "Cursor:pointer" onclick= "Showorderdetails (one)" > click </span>
</div>
</form>
</body>