0

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!

1
  • Never update anything in wp_includ folder. Better add you js in your theme folder & include it in your header file. Commented Jan 17, 2014 at 6:11

1 Answer 1

1

You just create a file or folder inside your wp-content/thems folder and save your script file after link it by header.php file inside your theam. Never change wp-include folder and content.

Normal link

<script type="text/javascript" src="/scripts/emailpage.js"></script>

Wordpress link

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/pathto/yourscript.js"></script>

For more references follow this link

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.