jeudi 26 mars 2015

html2canvas - It works in JSFiddle, but not in Wordpress


I am trying to get this code from JSFiddle to work in my WP install (http://ift.tt/1BoLEJy). I am having no luck. I am a novice JS user, but relatively experienced with WP. Here's what I've done so far:



  1. Copied HTML to the text editor of a new page in WP

  2. Copied the javascript code to a script box on the page and surrounded it with script tags <script type="text/javascript"></script>

  3. Copied the CSS to the script box and surrounded it with <style> tags


I haven't done anything else. I'm not sure if I need to upload any files, or add other items. Any thoughts?


Update:


Here's a test page I've created to try to replicate the JS Fiddle (goo.gl/dkXCEC)


I have added the html2canvas.js to my template's js folder. Then, I added the following enqueueing script to my functions.php file. This script was taken from http://ift.tt/1Hqk3ie (search for Google analytics example on the Codex page)



/* ------------ Enqueueing Script --------------- */

add_action( 'wp_enqueue_scripts', 'promo_canvas' );

/**
* Register and enqueue a script that does not depend on a JavaScript library.
*/
function promo_canvas() {
wp_register_script(
'html2canvas',
'/wp-content/themes/news-pro/js/html2canvas.js',
false,
'1.0',
true
);

wp_enqueue_script( 'html2canvas' );
}




Aucun commentaire:

Enregistrer un commentaire