An error occurred while accessing the Javascript object constructor.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.