1. Close the current window with JavaScript
Window. Close (), but it will prompt "the webpage you are viewing is trying to close the window. Close the window ?", How can I not bring up this prompt?
"If you open this webpage for the first time, window. close () will pop up a prompt, if this page is from another web page window. open () page, window. close () will not prompt;
<Script language = "JavaScript" type = "text/JavaScript">
Function Cl ()
{
Window. Opener = '';
Window. Close ();
}
</SCRIPT>
The above method is to assign an empty string to the opener of the current page (the empty string is not null, not empty), close the current page, and create a button to trigger this method;
<Input type = "Submit" onclick = "Cl ()" name = "Submit" value = "Submit"/> click it to close the current window without prompt;
It may also be used in the frame page, that is, the sub-page of the frame, so the above Code should be written
<Script language = "JavaScript" type = "text/JavaScript">
Function Cl ()
{
Window. Top. Opener = '';
Window. Top. Close ();
}
</SCRIPT>
After testing IE7 and IE8, even if the above method is used, a prompt is displayed (the href link is opened in the window), and the following script is used.
<Script language = "JavaScript" type = "text/JavaScript">
Function closewindow ()
{
Window. Opener = NULL;
Window. Open ('', '_ Self ','');
Window. Close ();
}
</SCRIPT>
Able to solve IE6, IE7, and IE8 simultaneously
2. All client events in the input box
Onblur-triggered when the focus is lost
Triggered when onchange loses focus and its value changes
Triggered when onclick is clicked with the left mouse button
Execute some code when onfocus gets the focus
Execute some code when onkeydown has a key to hold down
When the onkeyup button is released, some code is executed.
The onselect statement executes some code when the selected content changes.
Onselectstart: some code is executed when some text is selected.
3. How do I obtain the return value through the pop-up modal window and normal window?
Code of the parent page (parent. aspx)
<Script language = "JavaScript" type = "text/JavaScript">
Function OpenWindow (URL ){
// Var returnvalue = Window. showmodaldialog (URL, window, "dialogwidth = 320px; dialogheight = 300px; dialogtop = 20; dialogleft = 300; status = no; help = no; scroll = No "); // The modal window receives the return value by defining variables.
// Alert (returnvalue );
Window. open (URL, 'window', "dialogwidth = 320px; dialogheight = 300px; dialogtop = 20; dialogleft = 300; status = no; help = no; scroll = No ") // common form
}
Function compute evalue (value ){
Alert ("obtain the value by calling the js method on the parent page in the pop-up window:" + value)
}
</SCRIPT>
<Input type = "button" value = "Open subwindow" onclick = "OpenWindow ('child. aspx ')"/>
Code on the pop-up page (child. aspx)
<SCRIPT>
Function selectwhichone (value ){
// Window. returnvalue = value; // mode of the modal window. assign a value to the parent page of the modal window and receive the value from the parent page.
Window. opener. evalue (value); // you can call the js method defined on the parent page to pass the value as a parameter.
Window. Close ();
}
</SCRIPT>
<Div>
Here is the subpage
<Input id = "checkbox2" type = "checkbox" onclick = "selectwhichone ('my')"/> select me
<Input id = "checkbox1" type = "checkbox" onclick = "selectwhichone ('others')"/> select him
</Div>