Cause Analysis of null returned by the call function of externalinterface (as2)

Source: Internet
Author: User

Let's take a look at a common problem in as2. The interaction with flash in IE is abnormal ~! These situations include externalinterface in the question. the call function cannot obtain the return value when calling the JS function, the callback function of externalinterface cannot be normally called by JS, and Flash var cannot be normally transmitted to flash. These situations basically occur in IE. This is actually a bug in IE (I really want to dig his ancestral grave, but I am a civilized person, think about it and I am still patient). The solutions to the above problems are the same:

First, make sure that both the <Object> and <embed> labels exist. Sometimes you forget the <Object> label, so there will be problems in browsers other than IE.

Secondly, it is best to set allowScriptAccess to always in the <Object> and <embed> labels.

The most important thing is that the ID attribute must be set in the <Object> tag, and the name attribute must be set in the <embed> tag. The values of the two attributes must be the same. For example, <Object ID = "f_ckie">... <embed name = "f_ckie">. The <embed> label serves IE, while the <Object> label is prepared for browsers other than IE. (Inserting an embed label does not comply with W3C specifications, and the object is a standard label, f * ck ie ....)

The last thing to note is externalinterface. the return value accepted by call can only be of several types in AS, that is, object, array, string, and number. recursion or reference cannot be returned. Otherwise, only null can be obtained.

In addition, flashvar must be set in the <Object> and <embed> labels. In addition to custom tags, externalinterface. Call can only call several system global functions in Javascript, such as alert and confirm, while functions such as window. Open cannot call. Here is a trick. Eval can actually be called.

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.