未捕获的错误:调用 NPObject 上的方法时出错
我的页面上有一个 Flash 视频,如下所示:
<script type="text/javascript">
var flashvars = {
};
var params = {
movie: "VideoMain.swf",
quality: "high",
bgcolor: "#000000",
allowScriptAccess: "always",
wmode: "transparent"
};
var attributes = {
id: "VideoMain",
name: "VideoMain",
classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
width: "100%",
height: "100%"
};
swfobject.embedSWF("./video/VideoMain.swf", "myVideoContent", "100%", "100%", "11.0.0","", flashvars, params, attributes);
</script>
<div id="myVideoContent">
<h1>Oooppsss....you need flash or a newer version of flash</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
上面的内容被附加到 #VideoMain
然后我有以下内容:
$('#X.click').click(function(e) {
var flash = document.getElementById("VideoMain");
flash.sendToActionScriptPublishVideo(true);
});
失败并出现控制台错误:
Uncaught Error: Error calling method on NPObject.
(anonymous function)
jQuery.event.dispatchjquery.js:3256
jQuery.event.add.elemData.handle.eventHandlejquery.js:2875
任何想法可能是什么这里错了?谢谢
I have a flash video on my page as follows:
<script type="text/javascript">
var flashvars = {
};
var params = {
movie: "VideoMain.swf",
quality: "high",
bgcolor: "#000000",
allowScriptAccess: "always",
wmode: "transparent"
};
var attributes = {
id: "VideoMain",
name: "VideoMain",
classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
width: "100%",
height: "100%"
};
swfobject.embedSWF("./video/VideoMain.swf", "myVideoContent", "100%", "100%", "11.0.0","", flashvars, params, attributes);
</script>
<div id="myVideoContent">
<h1>Oooppsss....you need flash or a newer version of flash</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
The above gets appended into #VideoMain
Then I have the following:
$('#X.click').click(function(e) {
var flash = document.getElementById("VideoMain");
flash.sendToActionScriptPublishVideo(true);
});
This fails with the console error:
Uncaught Error: Error calling method on NPObject.
(anonymous function)
jQuery.event.dispatchjquery.js:3256
jQuery.event.add.elemData.handle.eventHandlejquery.js:2875
Any ideas what could be wrong here? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NPObject 是通过浏览器公开的任何“外部”代码的“接口”(外部,如对于 JavaScript 来说是外来的,否则它可能是浏览器自己的对象,例如全局 window 对象)。嵌入式 Flash 插件肯定会实现这个“接口”(因此浏览器将其视为另一个 NPObject)。
当您调用该对象上的方法时,有几个函数包装该调用,序列化传递到该对象并返回到浏览器运行时的数据。很难确定到底是什么不起作用,但一些常见的原因包括:
NPObject is an "interface" to any "foreign" code exposed through the browser (foreign, as in foreign to JavaScript, otherwise it may be browser's own objects, like the global window object for example). The embedded Flash plugin would certainly implement this "interface" (so the browser sees it as just another NPObject).
When you call a method on that object, there are several function that wrap that call serializing the data passed to the object and back to browser's runtime. It is difficult to tell for certain what exactly didn't work, but some common reasons would include:
我收到了同样的错误消息。仅当 Flash 进行外部接口调用并在 Flash 崩溃(无论出于何种原因)后返回时,才会出现此问题。我实施的修复是:检查 Flash 对象是否仍在运行,以及回调是否仍然是该对象的函数。
I was getting the same error message. The problem only occurred when Flash made an ExternalInterface call that returned after Flash crashed (for what reason whatsoever). The fix I implemented was: Check if the Flash object is still up and running and if the callback is still a function of that object.