zeroclipboard / zeroclipboard

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
http://zeroclipboard.github.io/
MIT License
6.61k stars 1.04k forks source link

IE8: flashBridge error - Object doesn't support this property or method #204

Closed jmp909 closed 10 years ago

jmp909 commented 11 years ago

Hi,

I'm getting this issue on our site and also on your main demo page in IE8 (Windows Vista, IE8.0.6001.18702) http://zeroclipboard.github.io/ZeroClipboard/

error - Object doesn't support this property or method

the failing line is this.flashBridge.setSize

if (this.ready()) this.flashBridge.setSize(width, height);

thanks

JamesMGreene commented 11 years ago

Sounds like you probably don't have Flash 10+ installed, and our current detection method for the Flash version ironically requires Flash.

Can you go to this page in your IE8 browser and send us either the pasted results or else the URL to your results page? https://aboutmybrowser.com

jmp909 commented 11 years ago
Browser            IE  
Browser Version    8.0  
User Agent String  Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)  
OS Type            Windows  
OS Name            Windows Vista  
Capture Time       2013-07-26 15:48:00 UTC  
Javascript         true  
Cookies            true 
Color Depth        
Screen             1280 x 1024  
Browser            1259 x 851  
Flash              10.0.45  
Java               false  
Language           
jmp909 commented 11 years ago

https://aboutmybrowser.com/lPYtWwfz

JamesMGreene commented 11 years ago

Hmm, weird. I'll take a look in the next week or two.

phoenixg commented 11 years ago

I've got the same problem:

Details Browser IE
Browser Version 8.0
User Agent String Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C)
OS Type Windows
OS Name Windows 7
Capture Time 2013-08-15 01:19:16 UTC
Javascript true
Cookies true Color Depth
Screen 1920 x 1080
Browser 1606 x 653
Flash 10.0.12
Java 1.6.0_29
Language

motpro commented 11 years ago

i have no issue on ie8 . good lucky :+1:

JamesMGreene commented 11 years ago

@phoenixg: You are seeing an error message "Object doesn't support this property or method" in Firefox? That seems unlikely as that error message is typically only used in IE.

phoenixg commented 11 years ago

@JamesMGreene sorry, I pasted wrong, I have corrected it above.

aptash commented 10 years ago

Hello! I see the same error message also:

SCRIPT438: Object doesn't support property or method 'setSize' ZeroClipboard.js, line 254 character 23

ZeroClipboard v1.2.1

Tested it in IE9 with IE8/IE7 browser mode enabled: Browser IE Browser Version 9.0 User Agent String Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; WOW64; Trident/5.0) OS Type Windows OS Name Windows Vista Capture Time 2013-10-28 11:30:05 UTC Javascript true Cookies true Color Depth 24 Screen 1280 x 800 Browser 1264 x 457 Flash 10.0.22 Java 1.6.0

I've got this error also on your http://zeroclipboard.org/

I saw this issue was opened 3 month ago. Any news? Thanks in advance for your support!

jmp909 commented 10 years ago

this.flashBridge.setSize is undefined in IE8

i guess it wouldnt be defined, because the function within flash is not actually "visible" to js

would this.flashBridge["setSize"] work better? (ie still work but not generate an error?)

JamesMGreene commented 10 years ago

i guess it wouldnt be defined, because the function within flash is not actually "visible" to js

That's actually not true, that's exactly what the Flash ExternalInterface.addCallback method achieves: https://github.com/zeroclipboard/zeroclipboard/blob/bd990ce1eb9460f8cbf7bc324f1805f3e14c4087/src/flash/ZeroClipboard.as#L96

would this.flashBridge["setSize"] work better? (ie still work but not generate an error?)

No, it would have the same problem as it does the exact same thing.

It's easy to make a patch to guard against this unhandled error... the bigger question is why the flashBridge is not working?

jmp909 commented 10 years ago

i'm thinking maybe that it is never actually created?.. you're dynamically creating an object but is it being fully added to the dom & js etc

http://stackoverflow.com/questions/5070432/javascript-how-to-dynamically-add-a-flash-file-swf-to-the-dom-so-ie-will-load

ie similarly to if you dynamically add a script tag to the dom, it doesnt actually just run because it wasnt there at runtime

http://stackoverflow.com/questions/2592092/executing-script-elements-inserted-with-innerhtml

JamesMGreene commented 10 years ago

i'm thinking maybe that it is never actually created?.. you're dynamically creating an object but is it being fully added to the dom & js etc

http://stackoverflow.com/questions/5070432/javascript-how-to-dynamically-add-a-flash-file-swf-to-the-dom-so-ie-will-load

I agree but not for the same reasons. I'm most suspicious that it has to do with your old versions of Flash Player... I'm thinking that the version we are compiling to is not being allowed to run in your older version of the Player, i.e. Issue #147.

ie similarly to if you dynamically add a script tag to the dom, it doesnt actually just run because it wasnt there at runtime

http://stackoverflow.com/questions/2592092/executing-script-elements-inserted-with-innerhtml

That's not actually an issue. That person was just "doing it wrong" (i.e. not in a cross-browser compliant fashion).

jmp909 commented 10 years ago

Hi, the last post here mentions a solution of inserting the div first and then adding the object http://forums.adobe.com/thread/433802

Maybe just swapping the last 2 lines of your function?! Sounds too simple ;)

These 2 I mean

  container.innerHTML = html;
  document.body.appendChild(container);

The other way round instead

JamesMGreene commented 10 years ago

@jmp909: Oh man, good find. As soon as you mentioned that, I immediately remembered that those lines used to be in reversed order and that I changed them for best practice and performance reasons. Drat it all, oldIE....

@jmp909: Any chance you can test this idea locally by just switching the order of those lines in your local copy?

jmp909 commented 10 years ago

that fixed IE8..

so regards this specific issue (204), i guess that's the resolution

but i'm getting this in IE9 either way round... (shall i move this to a different issue ticket?)

Line: 252 Error: Unable to get value of the property 'style': object is null or undefined

this.htmlBridge.style.top = pos.top + "px";

not sure why i hadnt noticed this before. probably had my debugger off

i think maybe you're only running _bridge() if detectFlashSupport is true, but my IE9 is returning false. so htmlBridge is never created? (i'm using v1.17 by the way but trying v.1.21 doesnt change it)

aptash commented 10 years ago

Yes, I can confirm that switching lines helps. But I don't have any other errors as @jmp909 said.

JamesMGreene commented 10 years ago

Oh, IE....

Thanks for the updates, @jmp909 and @Luckerz. Sounds like switching these lines will be the first fix but then we'll have to dig into the no-flash scenario @jmp909 described after that.

railsdev commented 10 years ago

@JamesMGreene IE 11 windows 8.1 it is again not working. Getting same error. Here we are adding object element dynamically. Instead of that can't we just add object element statically ?

JamesMGreene commented 10 years ago

@railsdev: I'm confused. Publishing a Flash object "statically" [typically] means putting the Flash embedding markup in the page's raw HTML, which a 3rd party JS library obviously cannot do. Did you mean something different...?

railsdev commented 10 years ago

Plugin insets global-zeroclipboard-html-bridge div dynamically on the page. Instead of that can I add flash embedded markup preloaded?

Another suggestion: http://pipwerks.com/2011/05/30/using-the-object-element-to-dynamically-embed-flash-swfs-in-internet-explorer/ This guy is using replaceChild instead of innerHTML.

JamesMGreene commented 10 years ago

No, there isn't any practical reason to allow static publishing for ZeroClipboard, especially as we need to generate a lot of params to get the configuration correct. If you'd like to do so, feel free to fork it and do so in your personal version.

JamesMGreene commented 10 years ago

Thank you for the link, though! That could prove very useful while working on Issue #288.

railsdev commented 10 years ago

By the way replaceChild did work for me to resolve IE issue.