Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Error when unloading page

53 replies [Last post]

Hi

I've run into a problem ...Hi

I've run into a problem where if the editor is written to the page dynamically using JavaScript, then when the page is unloaded in IE 7 I get a JavaScript error.

Error is:

Line: 53
Char: 3
Object required
Code: 0

Steps to reproduce are very simple:

Put this code in a html page and view in IE 7:
(Obviously you need to change the URLs to point to your player and a video)

<script type="text/javascript">
var str = '<p><embed width="233" height="207" src="player.swf" flashvars="file=/chips.flv" type="application/x-shockwave-flash"></embed>'
document.write(str);
</script>

Then simply refresh the page or attempt to navigate away from the page to see the error.

This is a very simplified example, but any method I've tried for writing the editor to the page with JavaScript exhibits the issue.

To show how this is true the following very different code will also produce the error:

<script type="text/javascript">
window.location.replace('player.swf?file=/chips.flv');
</script>

Player version is 4.2.95 (latest version at time of writing)

works fine it seems, i have not been able to recreate the problem in my IE7 flash10 - what is your flash version ?

but as you are using javascript anyway - how about trying with the swfobject ?

please see the readme.html in the download - it uses the swfobject v.1.5 which is also in the download (16.11.2008)
as well as the http://www.jeroenwijering.com/?page=wizard

for examples using the swfobject v.2.1 please see - http://www.jeroenwijering.com/?item=Javascript_API_Examples
and the examples list here - http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/

Mmm thanks, interestingly swfobject works.

FYI, I was wrong about writing with JavaScript, it happens with regular html tags too. Infact its worse with regular HTML. It gives JavaScript errors while loading not just while unloading.

The problem occurs in flash player 10 and 9, its easy to reproduce (ie I can't not reproduce it). And I can reproduce on multiple machines all running win xp.

Interestingly JW FLV Player 3 works without any errors.

So that leaves swfobject as the only way to use JW FLV Player

could you post a link to a page showing the error maybe ?

You have too many v3.x player flashvars in your code.

width, height, shownavigation, and fullscreen are NOT v4.x player supported flashvars!

Did you get any JS errors though?
Removing the flash vars makes no difference for me.

Nope, no JavaScript errors.

I have the same problem.
I use HTML code, rather than any Javascript as such. But I consistently get a "Line: 53, Char: 3, Object required, Code: 0" message (six times per instance of the JW Media player on the page).
I am using JW Player 4.0.46; Adobe Flash Player 9,0,115,0; Internet Explorer 7.0.6001.18000 (32 bit version on 64 bit Vista Home Premium).
Try the page http://dev.campuschurch.org.nz/talks/28/ (with script debugging enabled). IE7 should show six errors when you click (or type an address) to go to any other page.
The same code loads up on the page http://dev.campuschurch.org.nz/talks/ when you click "Listen". Try displaying two or three players and then going to another page - the number of errors will be the number of players shown times 6.
I'm convinced that it's the media player which is causing the errors - if you load the second URL but don't click Listen, it doesn't bring up any errors when you leave the page.
It took me some time to notice the error because I don't usually use IE, and neither Chrome nor Firefox bring up that error.
Does anyone have any ideas?

your page doctype is strict HTML 4 -

but you have 6 tags in the body (and one in the head) ending like this /> which is XHTML only !
<meta - <img - <br does not not use any closing tag in HTML 4 - the <embed tag you can close with </embed> instead...

anderson - doctype issues isn't the cause of the JS errors.

Check the basic example I posted earlier:
http://www.christopherbolt.com/jwflv/

I get the errors on every machine I've tried. 3 machines running windows XP and 1 running Vista. All Internet Explorer 7.
I've tried turning off virus checkers removing browser plugins. Making sure I have the latest flash player. The problem is still there.
Plus I have customers reporting the same issue. I'm not making this up, there is a problem here!

You have to give the poor little thing a name/id.

Otherwise, he's running around asking everybody — "Who am I?", "Who am I?", "Who am I?", "Who am I?".

And the browser's asking him — "Who are you?", "Who are you?", "Who are you?", "Who are you?".

It's like an echo, you know?

<object <strong>id="player" name="player"</strong> width="200" height="131" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">id/name can be any valid HTML element id/name string (MUST start with [a-zA-Z], it's best to stick to [a-zA-Z0-9] no "funny" characters).

oops, sorry Chris ! - i was checking Camerons page in the posting previous to my reply...

I've fixed most of my HTML4-strict validation errors for the http://dev.campuschurch.org.nz/talks/28/ page. Since in the standard <embed> doesn't have all those parameters available (eg width and height), I suppose I'll just have to go back to the javascript code which inserts the player into the DOM. I wanted to avoid that for the main /talks/ page I referred to, because things get added/removed/hidden dynamically there.

I have the same problem reloading my page with the player, I isolated the problem with just using this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>

<body>

<embed src="/js/JW_Player/player.swf" width="640" height="500" allowscriptaccess="always" allowfullscreen="true" flashvars="height=500&width=640&file=/tracks/ .... .flv" />

</body>
</html>

IE gives me 6 times the Object required error.

No problems if I use javascript for the player but I prefer to embed if possible.

@FraKtus,

See my post above, regarding name/id attributes.

@kLink

I saw it. If I use:

<embed src="player.swf" name="aa" id="bb" width="640" height="500" allowfullscreen="true" flashvars="height=500&width=640&file=/tracks/my_video.flv" />

I'ts still the same errors.

Try removing the classid attribute from the <object> tag.

@jdub

Not sure if I get your suggestion, the error is there if I put the classid or not in the <embed> tag. See the example above, it's so minimal.

I will go by using javascript to modify the DOM, this work on all browser without errors.

@FraKtus,

You should use the same name/id, otherwise I get confused.

<embed src="player.swf" <strong>name="aa" id="aa"</strong> width="640" height="500" allowfullscreen="true" flashvars="<strong><strike>height=500&width=640&</strike></strong>file=/tracks/my_video.flv" />

Also, the width and height flashvars are deprecated in the v4.x players. Since you didn't post all of your flashvars, maybe you have some other deprecated flashvars in there, causing your many headaches. :D

Please review the v4.x player supported flashvars here: http://code.jeroenwijering.com/trac/wiki/FlashVars

Note that all flashvars in italics are read-only, so you should not use them in your player code, only in some JavaScript for unknown purposes.

Thank you kLink your suggestion of adding the name and id attributes solved the problem. :-)

@Chris,

You're welcome. Good Luck!

Thanx
<object id="player1">
and
<embed name="player1" >
solved the problem ...

I'm seeing the same problem on Windows Vista Home Premium SP1, Internet Explorer 7.0.6001.18000, JW Player 4.3.132 and Flash Player 10.0.22.87.

Tried all the above, but nothing cures the problem. The error message pops up when closing a window containing the flash player. If you click on a link or enter a new URL to leave the page, no problem. Only closing the window triggers the object required bug.

Also, this only occurs with the embed html code and not the js code. XP and IE 6 didn't trigger the same error.

If I use JW FLV Player 3.16 or 3.17, IE 7 doesn't generate an error message upon closing the window. The error first occurs with 4.0.46.

I've the same problem, WinXP SP2, IE6.0 SP2, JW Player 4.2.90, Flash Player 10.0.12.36.
The embedded code without JS works fine in FF3, but in IE6 there is an error-message "object missing" when i close the page, going with a link to another site or typing another url is ok.
Code is

<embed
src="data/player.swf"
name="player1"
id="player1"
width="440"
height="330"
allowscriptaccess="always"
allowfullscreen="true"
flashvars="file=video.flv"
/>

Tried also
<object ...
but doesn't work too :-(

@Lead: do you also have an example page? These are strange issues, and it's difficult to assess how to work around them.

i also get the same error , 8 times , object required line 53 character 3

when closing page..

error is gone once i remove the embed code

tried all the suggestions above , no help

ie7.0.5 on xpsp2

it doesn't seem to be the way the code is done, it seems to be the swf itself because i tried everything and the only thing that made it go away was to purposely typo the swf url ( i pointed to a 404 swf just to test )

ok now i have narrowed it down , i took out every flashvar except the file, thinking it might be that but nope i still get the error

There is a routine in swfobject (the onUnload() function) that fixes this unload issue. Apparently, some IE versions throw an error when Flash players that connection to the page's javascript are unloaded. Best fixes would be to use:

* SWFObject or another javascript that removes all players from the page with an onUnload()
* the embed tag WITHOUT a name / id. That way, the javascript API isn't initialized and the error also doesn't occur.

In the latter case, no javascript interaction with the player can be made...

@JeroenW: Regarding your second suggestion, I'm seeing the error using the embed tag WITHOUT the name / id.

i am also seeing the error without using the id/name

i should specify using the embed and object without id/name still causes the problem

btw another simple fix is to run an ignore errors script on your page, thats what i did.

Jason, can you elaborate on the ignore errors script?

Unfortunately, this problem also exists in Internet Explorer 8.

@jeroenW

Please fix "Object Required" error.
Tried alll mentioned above but still got error, 8 TIMES.
I have to use <embed>, can't use javascript.

PLEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEASE.

Same problem here - please find a fix!! ID and Name parameters don't solve the issue

I am experiencing the same problem.

Thanks. The problem is fixed in 4.4.192

i have this problem in IE6

Jeroen, I've been customizing the source code of an older player which suffers from this error. Can you please point out which part of the source code I have to change to fix this?

I have the same issue: Object required. Error line 53. Char 3. And here is the script that loads automatically by IE when there is flash on a page:
function __flash__arrayToXML(obj) {
var s = "<array>";
for (var i=0; i<obj.length; i++) {
s += "<property id=\"" + i + "\">" + __flash__toXML(obj[i]) + "</property>";
}
return s+"</array>";
}
function __flash__argumentsToXML(obj,index) {
var s = "<arguments>";
for (var i=index; i<obj.length; i++) {
s += __flash__toXML(obj[i]);
}
return s+"</arguments>";
}
function __flash__objectToXML(obj) {
var s = "<object>";
for (var prop in obj) {
s += "<property id=\"" + prop + "\">" + __flash__toXML(obj[prop]) + "</property>";
}
return s+"</object>";
}
function __flash__escapeXML(s) {
return s.replace(/&/g, "&").replace(/</g, "&lt;").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
function __flash__toXML(value) {
var type = typeof(value);
if (type == "string") {
return "<string>" + __flash__escapeXML(value) + "</string>";
} else if (type == "undefined") {
return "<undefined/>";
} else if (type == "number") {
return "<number>" + value + "</number>";
} else if (value == null) {
return "<null/>";
} else if (type == "boolean") {
return value ? "<true/>" : "<false/>";
} else if (value instanceof Date) {
return "<date>" + value.getTime() + "</date>";
} else if (value instanceof Array) {
return __flash__arrayToXML(value);
} else if (type == "object") {
return __flash__objectToXML(value);
} else {
return "<null/>"; //???
}
}
function __flash__addCallback(instance, name) {
instance[name] = function () {
return eval(instance.CallFunction("<invoke name=\""+name+"\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));
}
}
function __flash__removeCallback(instance, name) {
instance[name] = null; // <-- this line causes the error
}

The weird thing is I have the same code on other pages and IE doesn't give me this error.

ok here is the solution for IE: you need to add <object> tage around <embed> tag like this:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="260" id="FlashID">
<param name="movie" value="player.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="" />
<embed src="player.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowscriptaccess="always" allowfullscreen="false" width="320" height="260" quality="high" wmode="transparent" flashvars=""></embed>
</object>

here is the fix

where "PLAYER" is the id name of the embed

<script type="text/javascript">
window.onbeforeunload = ieFix;
function ieFix() {
var ieFixElement = document.getElementById("PLAYER");
ieFixElement.parentNode.removeNode(ieFixElement);
}
</script>

p.s. this is a bug inherent with ie, not the longtail video player

Thank you very much kLink you helped me very wellllllll

Hi!

I just had the problem, I added the id attribute to the object tag and the name attribute on the embed tag (thanks by the way :)) and still no joy... Then I reallised that I didn't have a classid on my object tag:


<object id="externalVideo_4c0d12ec4ae6e" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="318" height="228">
<param name="movie" value="http://www.dailymotion.com/swf/video/abcdef">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed name="externalVideo_4c0d12ec4ae6e" type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/abcdef" width="318" height="228" allowfullscreen="true" allowscriptaccess="always"></embed>
</object>

That would do it ! ;) :)

@joe solution : Thanks

Below fix is awsome :)

where "PLAYER" is the id name of the embed

<script type="text/javascript">
window.onbeforeunload = ieFix;
function ieFix() {
var ieFixElement = document.getElementById("PLAYER");
ieFixElement.parentNode.removeNode(ieFixElement);
}
</script>

I kept running into this also when reload a page with YouTube player in it.

Here is another solution - we fix the bug in the Flash's __flash__removeCallback function like so:

function fixIELine53Bug() {
var IE = /*@cc_on!@*/false; // or any other IE detection method you want
if (!IE) { return; }
fixIELine53Bug.tries = 0; // static var to keep track of number of tries
if (window.__flash__removeCallback) {
window.__flash__removeCallback = function(instance, name) {
if (instance) {
instance[name] = null;
}
}
} else if (++fixIELine53Bug.tries <= 3) {
// just in case, we limit the number of tries
// window.__flash__removeCallback is not set up by flash yet,
// retry in one second
setTimeout(fixIELine53Bug, 1000);
}
}
fixIELine53Bug(); // or could run it from onload

Hi

In Jquery the solution :

Add class="player" on tagg <object>

And in jquery :

$(document).ready(function(){
window.onbeforeunload = ieFix;
function ieFix() {
$(".player").each(function() {$(this).remove();});
}
});

Dear Astgtciv,
I just want to say Thank You for sharing the solution. I have been trying to solve the same problem for days and could not solve it. Your solution cleared the error immediately. Thank you and thank you and thank you!

Another solution is to turn script access off:

<object ...
<param name="allowscriptaccess" value="never" />
....
</object>

and

<embed name="player1" ... allowscriptaccess="never" ... </embed>

hi all,I have download the latest version of jwplayer,and using only embed tag in my html page causes the "line 53 error".

Fortunately use following code solve this :

Add class="player" on tagg <object>

And in jquery :

$(document).ready(function(){
window.onbeforeunload = ieFix;
function ieFix() {
$(".player").each(function() {$(this).remove();});
}
});

Can you provide a link to where the error is happening?