In JavaScript-defined objects, either internal objects or user-defined objects. If the object is created from the modal dialog window and returned to the main window, we will not be able to get the constructor of the object in the main window ).
Perform the following two examples:
110000main.htm
< Html >
< Head >
< Title > Main Page </ Title >
< Meta Name = "Author" Content = "Birdshome @" />
</ Head >
< Body >
< Button Onclick = "Getvaluefromdialog ()" >
Click </ Button >
< Script >
VaR M_array = [];
Function Getvaluefromdialog ()
{
VaR Array = Required parameter showmodaldialog('dialog.htm ');
Alert (array. constructor );
// Alert (New m_array.constructor );
// Alert (new array. constructor );
}
</ Script >
</ Body >
</ Html >
2、dialog.htm
< Html >
< Head >
< Title > Modal Dialog </ Title >
< Meta Name = "Author" Content = "Birdshome @" />
</ Head >
< Body >
< Script >
Function Returnvalue ()
{
Window. returnvalue=['Modal'];
//Window. returnvalue = new function Foo (){};
Window. Close ();
}
</ Script >
< Button Onclick = "Returnvalue ()" > Close </ Button >
</ Body >
</ Html >
Close the window dialog.htm and execute alert (array. constructor). This will cause an exception during script running:
A runtime error has occurred.
Do you wish to debug ?
Line: 12
Error: unexpected call to method or property access.
// Unable to evaluate the expression. Catastrophic failure
However, the Javascript internal object and user-defined object are slightly different here. If it is a JS internal object, the constructor of the object we access will get an error immediately. Alert (array. constructor) is abnormal. If the user specifies an object, we can execute alert (array. constructor) to get a msgbox that displays "[object]". However, the contrutor still does not support any operations and execution of any methods, such as new and ,. tostring (), once executed, the exception "unable to evaluate the expression. catastrophic failure ".
This defect does not seem to have a great impact on us, but it is depressing for some functions implemented by Object-dependent constructor, for example, getting the name of a user-defined object, the singleton class of JavaScript object-oriented programming, and the last object clone method I made last time are all suspended.