Web page production in the pop-up window code
A set of common pop-up window usage
The following code collection of common pop-up window usage.
1, the most basic pop-up window code
<SCRIPTLANGUAGE=”javascript”>
<! —
window.open(‘page.html’)
–>
</SCRIPT>
The code is placed between the <SCRIPTLANGUAGE=”javascript”> tags and </script& gt; between them.
<! — and –> are working for some browsers with low versions.
window.open(‘page.html’) is used to control the pop-up new window page.html, if page.html is not under the same path as the main window, the path should be written in front, absolute path (http://) and relative path (… /) are acceptable. It’s fine to use single and double quotes, just don’t mix them.
This piece of code can be added to any location of the HTML, <head> and </head> between can, <body> between </body> can also be, the earlier the earlier the implementation, especially the page code is long, but also want to make the page pop up earlier as much as possible to put forward.
2, after setting up the pop-up window
Customize the appearance of this pop-up window, size, pop-up position to adapt to the specific circumstances of the page.
<SCRIPTLANGUAGE=”javascript”>
<! —
window.open(‘page.html’,’newwindow’,’height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no. location=no,status=no’)
// Write it on one line
–>
</SCRIPT>
Parameter explanation:
<SCRIPTLANGUAGE=”javascript”>js script start;
window.open the command to popup a new window;
‘page.html’ the filename of the popup window;
‘newwindow’ the name of the popup window (not the filename), non-required, can be replaced by a null ”;
height=100 the height of the window;
width=400 window width;
top=0 window pixel value from the top of the screen;
left=0 window pixel value from the left side of the screen;
toolbar=no whether to show the toolbar or not, yes to show;
menubar, scrollbars represent the menu bar and the scrollbars.
resizable=no whether to allow changing the window size, yes to allow;
location=no whether to show the address bar, yes to allow;
status=no whether to show the information in the status bar (usually that a file is open), yes to allow;
</ SCRIPT>
end of js script
3, control pop-up windows with functions
Complete code demonstration
<html>
<head>
<scriptLANGUAGE=”javascript “>
<! —
functionopenwin(){window.open(“page.html”, “newwindow”, “height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable =no,location=no,status=no”)
// Write it on one line
//–>
</script>
</head>
<bodyonload=” openwin()”>
… Any page content…
</body>
</html>
There is a function openwin() defined here, the content of which is to open a window. It has no purpose until it is called.
How to call it?
Method 1: <bodyonload=”openwin()”> pop-up window when the browser reads the page;
Method 2: <bodyonunload=”openwin()”> pop-up window when the browser leaves the page;
Method 3: Called with a connection:
<ahref=”#”onclick=”openwin()”> opens a window</a>
Note: the “#” used is a dummy connection.
Method 4: Called with a button:
<inputtype=”button “onclick=”openwin() “value=”open window”>
What is the code for the html of the popup window?
The materials you need to prepare are: computer, browser, html editor.
1, first of all, open the html editor, create a new html file, for example: index.html.
2, in the <script> tag in index.html, enter the js code: alert(‘helloworld!’);.
3, the browser to run the index.html page, this time the pop-up window “helloworld!
HTML window popup code
<!doctypehtml>
<html>
<head><title> Untitled document</title></head>
& lt;body>
<! –insert button start–>
<inputtype=”button” value=”Popup dialog box” onclick=”MsgBox()”/>
<! — Insert button to end –>
<! –Quoting JS code for the purpose of popping up the dialog box begins –>
<scriptlanguage=”javascript”>
functionMsgBox()//Declare the identifier
{
alert(“I’m the content of the dialog box”) )//popup dialog
}
</script>
<! –Quoting JS code for popup dialog box purposes end–>
</body>
</html>
Expanded:
Method Parameters in Detail
Parameters Explained:
The command window.open to popup a new window;
‘page.html’ filename of the popup window;
‘newwindow’ name of the popup window (not the filename), not required, can be replaced by an empty ”;
height=100 height of the window;
width=400 width of the window;
top=0 pixel value from the top of the screen. pixel value from the top of the screen;
left=0 window pixel value from the left side of the screen;
toolbar=no whether to show the toolbar or not, yes to show;
menubar, scrollbars means menu bar and scroll bar.
resizable=no allows the window size to be changed, yes;
location=no displays the address bar, yes;
status=no displays a message in the status bar (usually that a file is open), yes;
C# in a new Button click it can pop up a new window Form, this code so write?
Right-click on the name of your project, select [Add]-> [Windows Forms], and then give the new form a name, such as “MyForm”. Then write the code like this: x0aprivatevoidbtNewMake_Click(objectsender,EventArgse)x0a{x0a//How to write the pop-up window code here, thanks! x0aMyFormf=newMyForm();x0af.ShowDialog(); x0af. x0a}x0aIf you want to handle exceptions, you can write it like this:x0aprivatevoidbtNewMake_Click(objectsender,EventArgse)x0a{x0a//How should I write the code for the popup window here, thank you! x0aMyFormf=null;x0atryx0a{ x0af=newMyForm();x0af.ShowDialog();x0a}x0acatch(Exceptionexp)x0a{x0aMessageBox.Show(exp.Message, “Error”,MessageBoxButtons.OK, MessageBoxIcon.Error);x0a}x0a}