I am currently working with a javascript function that I have inserted inline into a wordpress post -- here is the code:
<script type="text/javascript">// <![CDATA[
document.getElementById('FBsharer').onclick = function () {
var url = 'https://www.facebook.com/sharer/sharer.php?u=';
url += encodeURIComponent(location.href);
window.open(url, 'fbshare', 'width=640,height=320');
};
// ]]></script>
The code works fine while inserted inline into my post--
But when I try to call the javascript in from an external file located in my wp_includes folder-- it no longer works.
I know that the JS file i am calling in from WP_includes works-- because I have other scripts in that file which work fine.
I am pretty new to JS-- so I am sure that im just formatting something wrong- or missing something simple.
Does anyone know how I can move this JS file from its current location (inline in my post) to my JS file that I am calling in from the wp_includes folder?
Thanks a ton!
wp_includfolder. Better add you js in your theme folder & include it in your header file.