JavaScript errors when closing document in Internet Explorer

Publishing Flash documents in HTML pages
Post Reply
jaymz
Posts: 14
Joined: Mon Jan 28, 2008 4:29 pm

JavaScript errors when closing document in Internet Explorer

Post by jaymz » Mon Jan 28, 2008 9:21 pm

Hi.. awesome product you guys have. I've been having a lot of fun with it, and only a very slight bit of trouble.

I am embedding print2flash documents into my website via the html/javascript from the printing application. This configuration loads and runs fine in IE6 and IE7, but when I close the browser window, I get around 40 javascript "Object required" error messages after the window disappears. I debugged these messages, which were thrown in this method:

Code: Select all

function __flash__removeCallback(instance, name) {
  instance[name] = null;
}
apparently because of this call:

Code: Select all

__flash__removeCallback(document.getElementById(""), "enableScrolling");
There appears to be one of these errors for every single p2f javascript callback. It shows the same "Object required" error again and again, but replace "enableScrolling" with "adjustToolbarColor", and then "setLanguage", and so on and so on in the second block of code.

It seems reasonable for IE to complain about indexing into an undefined element... I'm just not sure why my document seems to be trying to do that. Any ideas? Thanks so much =)

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: JavaScript errors when closing document in Internet Explorer

Post by staff » Tue Jan 29, 2008 8:38 am

It appears that this problem is caused by IE Flash plugin. __flash__removeCallback function is not related to Print2Flash. Sometimes we've met with such a problem in IE when loading SWF file directly in the browser. Are you loading into the browser the HTML file with embedded SWF or SWF file directly? If you load it directly, try to open an HTML page generated by Save as HTML button in Print2Flash application. If this does not help, try to re-install or update your IE Flash plugin.
Also, if you don't need Print2Flash Document API for your document, you may turn it off by checking "Disable Print2Flash Document API support" option in Document Options window before document conversion.

jaymz
Posts: 14
Joined: Mon Jan 28, 2008 4:29 pm

Re: JavaScript errors when closing document in Internet Explorer

Post by jaymz » Tue Jan 29, 2008 12:49 pm

staff wrote:Are you loading into the browser the HTML file with embedded SWF or SWF file directly? If you load it directly, try to open an HTML page generated by Save as HTML button in Print2Flash application.
I am loading the SWF dynamically via javascript into an HTML page. I tried the test that you suggested: I published the HTML page generated by the printing application directly to my webserver. As it turns out, I could open and close the page just fine without any errors! Perhaps my error is being caused because I am inserting the object/embed code dynamically?
staff wrote:If this does not help, try to re-install or update your IE Flash plugin.
I had just installed flash on my testing machine before I saw this error. As a last resort, I did reinstall my flash plugin... but the error still occurs.
staff wrote:Also, if you don't need Print2Flash Document API for your document, you may turn it off by checking "Disable Print2Flash Document API support" option in Document Options window before document conversion.
Unfortunately, this would be the easy option, but I will be making use of the API via javascript sometime in the near future. Thanks for all of the suggestions!

jaymz
Posts: 14
Joined: Mon Jan 28, 2008 4:29 pm

Re: JavaScript errors when closing document in Internet Explorer

Post by jaymz » Fri Feb 08, 2008 7:44 pm

I have verified this problem. It happens only when I insert the HTML dynamically via JavaScript. [Unfortunately, this is the only option for my application.] Here is the code that is used in Windows XP with IE6, where I can reproduce the problem 100% of the time:

Code: Select all

'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
+ 'id="doc" width="100%" '
+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + RequiredMajorVersion + ',' + RequiredMinorVersion + ',' + RequiredRevision + ',0">'
+ '<param name="movie" value="' + fileURL + '" /><param name="quality" value="best" />'
+ '<param name="allowScriptAccess" value="sameDomain" />'
+ '<param name="wmode" value="opaque" />'
+ alternateContent
+ '</object>';
That string is then inserted into my page using Prototype's Element.insert.

See any snags? I'm at a total loss here. Thanks in advance!

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: JavaScript errors when closing document in Internet Explorer

Post by staff » Sun Feb 10, 2008 12:25 pm

Try to use other methods for inserting content in iE: insertAdjacentHTML, insertAdjacentElement or insertBefore

jaymz
Posts: 14
Joined: Mon Jan 28, 2008 4:29 pm

Re: JavaScript errors when closing document in Internet Explorer

Post by jaymz » Mon Feb 11, 2008 2:53 pm

staff wrote:Try to use other methods for inserting content in iE: insertAdjacentHTML, insertAdjacentElement or insertBefore
Thanks again for your helpful suggestions. I tried all of the above insertion methods, and the same behavior still showed up.

Unless you have some other trick up your sleeve, I'm beginning to think that we might have to chalk this up to some sort of IE/Flash/JavaScript interaction bug. I feel like somebody on the Microsoft or Adobe payroll should be wrestling with this one instead of me. Heh. Either way, please let me know if you have any more ideas, or if you hear about a fix in the future!

Another thing that I should mention is that I tried testing on a fresh virtual environment with XP/IE6 and didn't receive the error... ... until I installed the most recent windows updates. Maybe some recent security change is causing this? =/

mamaco
Posts: 1
Joined: Wed Apr 16, 2008 8:12 pm

I got same script error with Mootool Lib

Post by mamaco » Wed Apr 16, 2008 8:33 pm

flash probably find the HTML element while page is rendering,but it might miss the instance of dynamic object created by Prototype,so I use simple javascript instead of Prototype lib,it works well.

jaymz
Posts: 14
Joined: Mon Jan 28, 2008 4:29 pm

Re: I got same script error with Mootool Lib

Post by jaymz » Thu Apr 17, 2008 12:05 pm

Hi mamaco. Thanks so much for your reply! I'm very excited to hear that you have found a work-around for this problem.
mamaco wrote:I use simple javascript instead of Prototype lib,it works well.
Could you please clarify what you mean by "simple javascript"? I have tried using native javascript insertion methods instead of Prototype's methods, but they all produce the same errors. An example would be very helpful. Thanks again.

Post Reply