WordPress.org

Ready to get started?Download WordPress

Forums

[Copy in clipboard] Anyone know how to solve this problem? (3 posts)

  1. The Night Fox
    Member
    Posted 3 years ago #

    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: http://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="http://www.google.com" class="copy" title="text to be coopied">Click Here To Copy</a>

  2. jwilliamsua
    Member
    Posted 2 years ago #

    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..

  3. guilliam
    Member
    Posted 2 years ago #

    have the same question as jwilliamsua

Topic Closed

This topic has been closed to new replies.

About this Topic