Search code examples
javascriptdreamweaver

Javascript won't run


I have tried numerous pieces of JavaScript in my simple HTML file. However, none of them work. I am using Adobe Dreamweaver CS4 and have tried using both Safari and Firefox browsers

I've also done some tests, and JavaScript is enabled in both browsers. The problem is within my page or Dreamweaver. Could anyone give me some suggestions to find the issue?

This is an example of the code I'm trying to use.

    <div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://facebook.com/facebook" data-send="false" data-width="450" data-show-faces="false"></div>

I placed the first part just under my tag and the second part in a table in the body.


Solution

  • Problem is that protocol-less URLs inherit the protocol used to open the current document, that is, they usually do not work with the file:/// URI scheme.

    To test locally without such problems, install a local web server - XAMPP, WAMP, EasyPHP - and run the local files through the http:// protocol. Alternatively, you can upload it to your webserver for testing as well.

    Side-note: FB won't load using the file:///, it needs to be loaded on a web server (a localhost one will work as well).

    Fiddle