1. Close the browser page with high compatibility
// Close the webpage. Firefox is not supported (Firefox returns to the previous page)
// FireFox non-window. open () and other pop-up pages, you need to enter about: config in the address bar, and then change dom. allow_script_to_close_windows to true to achieve the desired effect.
Function CloseWebPage (){
If (navigator. userAgent. indexOf ("MSIE")> 0 ){
If (navigator. userAgent. indexOf ("MSIE 6.0")> 0 ){
Window. opener = null; window. close ();
}
Else {
Window. open ('', '_ top'); window. top. close ();
}
}
Else if (navigator. userAgent. indexOf ("Firefox")> 0 ){
Window. history. go (-1 );
}
Else {
Window. close ();
}
}
// Close the webpage. Firefox is not supported (Firefox returns to the previous page)
// FireFox non-window. open () and other pop-up pages, you need to enter about: config in the address bar, and then change dom. allow_script_to_close_windows to true to achieve the desired effect.
Function CloseWebPage (){
If (navigator. userAgent. indexOf ("MSIE")> 0 ){
If (navigator. userAgent. indexOf ("MSIE 6.0")> 0 ){
Window. opener = null; window. close ();
}
Else {
Window. open ('', '_ top'); window. top. close ();
}
}
Else if (navigator. userAgent. indexOf ("Firefox")> 0 ){
Window. history. go (-1 );
}
Else {
Window. close ();
}
}
Ii. window. showModalDialog () Extension
<Span style = "font-size: 13px;"> // open the ModalDialog subwindow and obtain the return value.
Function ModalDialogOpen (wUrl, wWidth, wHeight ){
If (window. showModalDialog! = Null) // IE judgment
{
Var returnvalue = window. showModalDialog (wUrl, "_ self", "dialogWidth:" + wWidth + "px; dialogHeight:" + wHeight + "px; status: no; help: no; scrolling = yes; scrollbars = yes; center = yes ");
If (! Returnvalue ){
Returnvalue = window. ReturnValue ;;
}
Return returnvalue;
}
Else {
This. returnAction = function (strResult ){
If (strResult! = Null)
Return strResult;
}
Window. open (wUrl, "", "width =" + wWidth + ", height =" + wHeight + ", menubar = no, toolbar = no, location = no, scrollbars = yes, status = no, modal = yes ");
}
}
// Close the ModalDialog subwindow and return the value
Function ModalDialogClose (val ){
If (window. showModalDialog! = Null) // IE judgment
{
If (navigator. userAgent. indexOf ("Chrome")> 0 ){
// Chrome support
Window. opener. ReturnValue = val;
} Else {
Parent. window. returnValue = val;
}
Window. close (); // firefox does not support
}
Else {
Window. opener. returnAction (val );
Top. close (); // both IE and FireFox support
}
}
</Span>
<Span style = "font-size: 13px;"> // open the ModalDialog subwindow and obtain the return value.
Function ModalDialogOpen (wUrl, wWidth, wHeight ){
If (window. showModalDialog! = Null) // IE judgment
{
Var returnvalue = window. showModalDialog (wUrl, "_ self", "dialogWidth:" + wWidth + "px; dialogHeight:" + wHeight + "px; status: no; help: no; scrolling = yes; scrollbars = yes; center = yes ");
If (! Returnvalue ){
Returnvalue = window. ReturnValue ;;
}
Return returnvalue;
}
Else {
This. returnAction = function (strResult ){
If (strResult! = Null)
Return strResult;
}
Window. open (wUrl, "", "width =" + wWidth + ", height =" + wHeight + ", menubar = no, toolbar = no, location = no, scrollbars = yes, status = no, modal = yes ");
}
}
// Close the ModalDialog subwindow and return the value
Function ModalDialogClose (val ){
If (window. showModalDialog! = Null) // IE judgment
{
If (navigator. userAgent. indexOf ("Chrome")> 0 ){
// Chrome support
Window. opener. ReturnValue = val;
} Else {
Parent. window. returnValue = val;
}
Window. close (); // firefox does not support
}
Else {
Window. opener. returnAction (val );
Top. close (); // both IE and FireFox support
}
}
</Span>
From tu jiankai's column