简体   繁体   中英

Syntax Error in Javascript Code

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM