Note that there are some explanatory texts on larger screens.

plurals
  1. POZeroClipboard user script adding in mouse over, working in firefox, but not chrome
    primarykey
    data
    text
    <p>I am using zeroclipboard to add a "copy" link to each row in a fairly large list, within a user script. To accomplish that, I using a method similar to the one listed on <a href="http://www.codelixir.com/zero-clipboard-multi-instance/" rel="nofollow">this page</a>, where the ZeroClipboard.Client() element for each row is created when the user mouses over the row. This is working great in FireFox, but not in Chrome. </p> <p>Also as a note: I copied the contents of the ZeroClipboard.js file into the user script itself instead of including it in an external file.</p> <p>Here is the markup that creates the copy button for each element<br> <code>&lt;span style="color:blue; text-decoration:underline; cursor:pointer" id="copy_'+id+'" class="CopyLink" link="'+url+'" onmouseover="clipboard.add(this)"&gt;Copy&lt;/span&gt;</code></p> <p>Here is the code segment that adds the clipboard's client object:</p> <pre><code>function main(){ window.clipboard = { load: function (){ if(!clipboard.initialized){ ZeroClipboard.setMoviePath("http://www.swfcabin.com/swf-files/1343927328.swf"); clipboard.initialized=true; console.log("Clipboard intialized"); } }, add: function(element){ clipboard.load(); var clip = new ZeroClipboard.Client(); console.log('Clipboard client loaded: ' + element.id); clip.glue(element, element.parentNode); console.log('Clipboard glued: ' + element.id); clip.setText(element.getAttribute('link')); console.log('Clipboard text set: ' + element.getAttribute('link')); clip.addEventListener('complete',function(client,text) { console.log('Clipboard copied: ' + text);//doesn't fire in chrome }); clip.addEventListener('load',function(client) { console.log('Clipboard loaded: ' + element.getAttribute('link')); }); } } //other code in user script including injecting above markup //as well as contents of ZeroClipboard.js window.ZeroClipboard = { ... } } var script = document.createElement("script"); script.appendChild(document.createTextNode('('+main+')()')); (document.head || document.body || document.documentElement).appendChild(script); </code></pre> <p>In this block, every console.log fires in FireFox when I mouse over and click the copy span, but in chrome, all except the 'complete' listener fire. I was able to verify that ZeroClipboard is working in my Chrome by using the example on <a href="http://davidwalsh.name/demo/zero-clipboard.php" rel="nofollow">this page</a>. I am also able to verify that the flash object is being added to the page in the correct location, but it is simply not responding to a click. </p> <p>Since the zeroclipboard code is no longer being maintained according to the <a href="http://code.google.com/p/zeroclipboard/" rel="nofollow">site</a>, I'm hoping someone out there can help me out. I'm thinking there is possibly some issue with dynamically adding the embedded flash objects in chrome on mouseover, or perhaps some difference between user scripts in chrome vs firefox with greasemonkey? Any help would be greatly appreciated, thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload