Javascript error in Internet Explorer
I have a problem with a js script running in Internet Explorer.
Basically the script runs fine in Firefox, but I need to embed it into the webbrowser control in a silverlight application, for which it has to run error free in the Internet Explorer engine.
Running it in the IE produces an "Expected object" error in the following line:
$f("player", "player.swf", {
How could this be rewritten to also work in IE?
Here is the complete script:
$f("player", "player.swf", { key: '#@18a1aaa6552d45a2cfe', log: { 开发者_JAVA技巧level: 'debug', filter: 'org.flowplayer.cluster.*' }, clip: { url: 'live3', live: true, provider: 'rtmp', autoBuffer:true, bufferLength:10, scale:'fit', connectionProvider: 'cluster', onStart: function(clip){ } }, canvas: {backgroundImage: 'url(staytuned.jpg)'}, onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}}, contextMenu: [ 'player 1.1', {'About ...' : function() { location.href = "url/?page=aboutus";}}, {'Contact ...' : function() { location.href = "url/?page=contactus";}}, {'More Casts ...' : function() { location.href = "url/?page=casts";}}, ], plugins: {
overlay: {
url: 'overlay.swf',
top: 0,
right: 0,
width: 854,
height:450,
zIndex:3
},
rtmp: {
url: 'rtmp.swf'
},
cluster: {
url: 'cluster.swf',
netConnectionUrl: 'url',
hosts: [
{host:'url'},
{host:'url'}
]
},
controls: {
autoHide: false,
url:'url',
zIndex:5
},
gatracker: {
url: "analytics.swf",
trackingMode: "Bridge",
bridgeObject: "pageTracker"
}
}
});
Thanks, Andrej
First answer was incorrect. See comments for details.
Edit
The problem is likely that $f is not defined at the time you're trying to call it. Place alert(typeof $f);
on the line immediately before the line causing the error. If it doesn't alert function
, them I'm right.
Make sure you're including the script that contains the definition for $f before you try to call it.
Goto www.jslint.com. Paste this entire script into the top window and click the "jslint" button below it.
You'll find that onError is malformed:
onError:function(err){canvas: {backgroundImage: 'url(taytuned.jpg)'}},
it should read more like:
onError:function(err) {
var canvas = {backgroundImage: 'url(taytuned.jpg)'};
return canvas;
},
There's a similar issue a few lines below.
And I suspect that "taytuned.jpg" needs to be enclosed within quotes, but it's not my script.
精彩评论