Reputation: 457
I am trying to copy content to clipboard using https://github.com/zeroclipboard/ZeroClipboard. It seems a good library, but I am getting the error 'Error calling method on NPObject.' when the copy button (a flash) is hovered.
Seems like a flash security problem, but I am able to load the flash content.
Any ideas?
Upvotes: 3
Views: 1935
Reputation: 2506
Or else your domain is not ssl secured i.e your protocol is http
instead of https
so you should alter your swf link from
To
For further details please check Cross-Protocol Limitations
topic in the following documentation
http://www.kellyjandrews.com/zc/guides/limitations/protocol/
Upvotes: 0
Reputation: 46
Please add "trustedDomains : [*]"
Tha't how I fixed my problem.
var clip = new ZeroClipboard(document.getElementById("copy-button"), {
trustedDomains: [ "*" ],
moviePath: "http://assets.dev.alipay.net/gallery/zeroclipboard/1.2.2/ZeroClipboard.swf"
});
For more details: https://github.com/zeroclipboard/zeroclipboard/issues/103
Upvotes: 1
Reputation: 41
In versions after 1.1.7, if you hosted "ZeroClipboard.swf" on a different domain than the hosting page, you need to set "allowScriptAccess" to "always" other than "sameDomain", also "trustedDomains" should contain current page domain.
ZeroClipboard.setDefaults( { moviePath:'http://YOURSERVER/path/ZeroClipboard.swf',allowScriptAccess: "always",trustedDomains: location.hostname } );
Upvotes: 4
Reputation: 7366
In case this helps anyone else, I managed to make this error go away for my setup (developing locally at http://localhost:3000
and loading the Flash file from cdnjs. CoffeeScript:
if ZeroClipboard?
ZeroClipboard.setDefaults
moviePath: "//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.1.7/ZeroClipboard.swf"
trustedOrigins: [window.location.protocol + "//" + window.location.host]
trustedDomains: window.location.hostname
allowScriptAccess: "always"
Note that trustedDomains
is the key here. Even though it's supposedly deprecated in 1.1.7, removing it (for me at least) causes the dreaded Error calling method on NPObject
error to return.
Upvotes: 0
Reputation: 457
I got it work. It was a same origin security model breech. My web apps subdomain was 'WWW' but the flash content was served from 'CDN'. Just rendered both the contents from same subdomain.
Thanks.
Upvotes: 2
Reputation: 10040
I just updated from 1.0.7 to 1.1.7 yesterday and I'm experiencing the same issue... I'm wondering if they broke something with a commit they did yesterday because this is the only post I've seen about the issue.
~Seth
Upvotes: 0