0

My text editor is telling me I have a syntax error in my Javascript. It is somewhere in this line:

<script type="text/javascript"> if (!window.mstag) mstag = {loadTag : function(){},time : (new Date()).getTime()};</script> 

Jslint tells me that I have an "Unexpected '<'." in Line 1, Character 1. So that, I'm guessing, means I have an error in the script type itself, which doesn't make much sense to me. I'm a newb, sorry if this is a super-basic question. Thanks in advance for any help you can give me.

1
  • 2
    There is no syntax error. What editor tells you there is one? Commented Feb 27, 2014 at 19:51

1 Answer 1

6

JSLint validates javascript. What you have here is a HTML <script>tag with javascript inside. You should only paste in the javascript to JSLint:

if (!window.mstag) mstag = {loadTag : function(){},time : (new Date()).getTime()};

My guess is that you've use <script type="text/javascript"> inside a .js file and your editor has no idea what is going on - is that correct?

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

3 Comments

Ok, thank you! I still have errors, but I will dig in further!
@Anne If it's because it's in a separate .js file you should not use any <script> tags. They're only used when outputting HTML.
This is actually a snippet for Hubspot that isn't working correctly. I was just hoping there would be some small but noticeable error in the coding...it looks like it might be a bigger problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.