• So I found a neat facebook slide like script from monkeyphysics, works great all i do is with a floating widget insert this:

    <script
       type="text/javascript"
       src="https://www.monkeyphysics.com/fb-sidelike/fb-sidelike.js"
       fbpage='facebookpagename'></script>

    It’s three files, two pictures and one javascript which calls a facebook social plugin and mootools from googleapis.

    Obviously i want it on my site and i want to modify it to make a sliding youtube channel iframe as well but… before i even get there i can’t get this to work if i upload it to my site…

    I tried a few different URL i tried to upload in theme folder, i tried to upload to wp-include

    /wp-content/themes/mantra/js/side-slidebar/fb-sidelike.js

    I tried under /js/ by itself

    I tried also /wp-includes/js/

    In fact i managed to get the exact url and open in browser to view the script… but when i try to insert with the javascript nothing happens?????

    I installed better-wp-security is this blocking it somehow? Doesn’t make sense.. as the mantra theme includes javascripts itself.

    Please help me out. Has nothing to do with mantra, i have customized the site on my own but the problem is just getting my uploaded .js file to even load ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Go ahead and upload the javascript to your theme root (we’ll call it my.js for the example). Then, in your functions.php add:

    add_action('wp_enqueue_scripts','enqueue_my_javascript');
    function enqueue_my_javascript() {
    wp_register_script('my.js','my.js');
    wp_enqueue_script('my.js');
    }

    You need to hook javascript file calls to wp_enqueue_scripts (outside of the admin section). Make sense?

    Thread Starter muslimbodybuilding

    (@muslimbodybuilding)

    I just did that… except i called it fb-sidelike.js. I uploaded the files to mantra’s root folder (mantra is theme name)

    I put in functions.php:

    add_action('wp_enqueue_scripts','enqueue_my_javascript');
    function enqueue_my_javascript() {
    wp_register_script('fb-sidelike.js','fb-sidelike.js');
    wp_enqueue_script('fb-sidelike.js');
    }

    And I put this in page:

    <script
       type="text/javascript"
       src="fb-sidelike.js"
       fbpage='mypage'></script>

    Didn’t work no sliding side bar appears.. nothing happens basically ??

    Help a man out, here at a loss for words what’s wrong.. need to fix this so i can start working on extra javascript for youtube too… really weird that it works if its outside of my site but not if i upload…

    Thread Starter muslimbodybuilding

    (@muslimbodybuilding)

    im sorry for sounding totally newb.. i am not understanding it one bit… it works if its hosted elsewhere and i call it simply like i did in first post.. but if i upload it to the site.. it wont load…

    The javascript i wnat to run also runs this:

    https://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js

    [Moderator note: If you don’t want to wait, you can ask https://jobs.wordpress.net for support]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unable to run javascript from page thats hosted but able to hosted elsewhere…’ is closed to new replies.