I
I
Ivan Ignatiev2015-10-12 13:38:36
JavaScript
Ivan Ignatiev, 2015-10-12 13:38:36

Mysterious SintaxError: what is the error?

I will not understand in any way why in twenty times checked up and couple of times the rewritten code the syntactical error takes off:
SyntaxError: missing ; before statement after var fb.widgets = d.querySelectorAll('.hLike.facebook');

var d = document;
  var url = d.location.href;
  var s = 'script';
  
  var firstScript = d.getElementsByTagName(s)[0];

  /* fb */
  var fb = {
    id: 'facebook-jssdk',
    appId: '1550284425231361'
  };
  var fb.widgets = d.querySelectorAll('.hLike.facebook');
   //На месте сего коммента SyntaxError: missing ; before statement
  for(var i in fb.widgets) {
    var widget = fb.widgets[i];

    var widgetFrame = d.createElement('div'); 
    widget.appendChild(widgetFrame);

    widgetFrame.class = 'hLike-frame fb-like';
    widgetFrame['data-href'] = url;
    widgetFrame['data-layout'] = 'button';
    widgetFrame['data-action'] = 'like';
    widgetFrame['data-show-faces'] = 'false';
    widgetFrame['data-share'] = 'true';
  }

  if (!d.getElementById(id)) {
    fb.js = d.createElement(s); fb.js.id = fb.id;
    if(!d.getElementById('fb-root')) 
      fb.root =	d.createElement("div"); fb.root.id = 'fb-root';
    
    fb.js.src = "//connect.facebook.net/ru_RU/sdk.js#xfbml=1&version=v2.5&appId=1"+fb.appId;
    firstScript.parentNode.insertBefore(fb.js, firstScript);
  }

//......

What can be wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kravchenko, 2015-10-12
@0x9d8e

var fb.widgets
try to replace with
fb.widgets

V
Vladimir Martyanov, 2015-10-12
@vilgeforce

Probably the text of the error and where it crashes is completely unnecessary information!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question