我打电话到嵌入在使用ExternalInterface一个HTML页面中的Flash应用程序。 下面code正常工作(我用一个按钮来测试):
$(文件)。就绪(函数(){
$(#键)。点击(函数(){
VAR应用=的document.getElementById('的applicationID)
console.debug(表观)
app.pageUnloading()
})
})
所以这个调用到Flash应用程序精细和打印:
<嵌入ID =的applicationIDWIDTH =600HEIGHT =400ALIGN =中间类型=应用程序/ x-冲击波闪光PLUGINSPAGE =HTTP ://www.adobe.com/go/getflashplayer的allowScriptAccess =导航特殊NAME =FlexMoedersBGCOLOR =#CCCCCC品质=高SRC =ApplicationID.swf>
但是,当我使用由ID获取元素的jQuery的$#方法,我收到了不同的对象返回:
$(文件)。就绪(函数(){
$(#键)。点击(函数(){
VAR应用= $(#的applicationID)
console.debug(表观)
app.pageUnloading()
})
})
当我用这个告诉我:
app.pageUnloaded不是一个函数
和以下被打印
[嵌入#的applicationID]
我也曾尝试:
VAR应用= $(#的applicationID)。VAL()
VAR应用= $(#的applicationID)。得到(0)
但仍然没有成功。没有人有任何想法在这里?
解决方案 VAR应用= $('#的applicationID')[0]
或
VAR应用= $('#的applicationID)。得到(0)
应该做同样的事情,
VAR应用=的document.getElementById('的applicationID)
I'm calling into a flash app embedded in a html page using the ExternalInterface. The following code works fine (I'm using a button to test):
$(document).ready(function(){
$("#button").click(function(){
var app = document.getElementById('ApplicationID')
console.debug(app)
app.pageUnloading()
})
})
So this calls into the flash app fine and prints:
<embed id="ApplicationID" width="600" height="400" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowscriptaccess="sameDomain" name="FlexMoeders" bgcolor="#cccccc" quality="high" src="ApplicationID.swf">
But when I use the jquery $# method of getting an element by id, I receive a different object back:
$(document).ready(function(){
$("#button").click(function(){
var app = $("#ApplicationID")
console.debug(app)
app.pageUnloading()
})
})
When I use this I'm told:
app.pageUnloaded is not a function
and the following is printed:
[embed#ApplicationID]
I have also tried:
var app = $("#ApplicationID").val()
var app = $("#ApplicationID").get(0)
But still no success. Does anyone have any ideas here?
解决方案var app = $('#ApplicationID')[0]
or
var app = $('#ApplicationID').get(0)
should do the same thing as
var app = document.getElementById('ApplicationID')