• There is an awesome plug-in called copy in clipboard that is based on a project called Zero Clipboard. Basically it overlays a html link with a flash movie and when you click it, it copys text to your clipboard and can open a new webpage using javascript.

    The pulg-in works great but I can’t figure out how to get it to open in a new window. Using target=”new” fails to open the link in a new window so I think this can only be achieved be editing the plug-in’s code, but maybe there is another way.

    This is the code for the plug-in

    <?php
    /*
    Plugin Name: Copy in clipboard
    Description: Small plugin that copy text into clipboard (onClick) from title tag using zeroclipboard.
    Author: CoYoTe
    Version: 0.6.1
    Author URI: https://www.ivanherceg.in.rs
    */
    	wp_register_script( 'jquery', WP_PLUGIN_URL . '/copy-in-clipboard/jquery-1.4.2.min.js' );
    	wp_enqueue_script('jquery');
    	add_action('wp_head', 'copyinclipboard', 15);
        wp_register_script( 'zeroclipboard', WP_PLUGIN_URL . '/copy-in-clipboard/zeroclipboard.js' );
        wp_enqueue_script( 'zeroclipboard' );
    
    function copyinclipboard() {
    echo '<script type="text/javaScript">
    ZeroClipboard.setMoviePath( \''. WP_PLUGIN_URL . '/copy-in-clipboard/zeroclipboard.swf\' );
    jQuery(document).ready(function() {
        jQuery(\'.copy\').mouseover(function() {
            var txt = jQuery(this).attr("title");
    		var url = jQuery(this).attr("href");
            clip = new ZeroClipboard.Client();
    		clip.setHandCursor(true);
            clip.setText(txt);
            clip.glue(this);
            clip.addEventListener(\'complete\', function(client, text) {
    			alert("Text copied to clipboard!" );
    			if (url!=undefined){							//this is for
    				window.location=url;						//<a href links
    			}												//to do it
            });
        });
    });
    </script>';
    }
    ?>

    And this is the code that is entered into a wordpress post:

    <a href="https://www.google.com" class="copy" title="text to be coopied">Click Here To Copy</a>

Viewing 2 replies - 1 through 2 (of 2 total)
  • can you be more clear about how to make this plugin work. I dont think the plugin has a good description of how to use. Once installed, what do i place before and after the text that i want to be copied? Thanks..

    have the same question as jwilliamsua

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Copy in clipboard] Anyone know how to solve this problem?’ is closed to new replies.