-2

I keep getting a error saying unexpected token var

on these lines

var isSplash =true;
//------DocReady-------------
$(document).ready(function()
if(location.hash.length == 0){
location.hash="!/"+$('#content > ul > li').eq(2).attr('id');

Help please im a n00b at javascript

thanks

user1612508
  • 25
  • 1
  • 6

1 Answers1

0

The line itself is perfectly valid javascript. The line before it, however, is most likely not. If your interpreter is expecting a closing brace } or closing paren ) and it sees "var" instead, you will get the error message Unexpected token: var.

Check the line before the error for any syntax errors.

edit: The line before has a closing script tag as a string. The browser will see this as a closing script tag, regardless of the fact that it is in a string, and break the rest of your script.

To fix the issue, simply split your string in the middle of the closing script tag. e.g.

document.write('<script src="'+ url + '" type="text/javascript" ></scr' + 'ipt>');

See this related question.

Community
  • 1
  • 1
jbabey
  • 45,965
  • 12
  • 71
  • 94