JSLint Expected '%' and instead saw '%'
I have code that starts off with
<%
function selected()
{
at the start of my code and JSLint gives the error
Problem at line 1 character 1: Expected '%' and instead saw '%'.
This code works just fine and has for a long time. I was just trying to开发者_C百科 run this against JSLint hoping to improve my code. JSLint stops at this error and will not scan the rest of the code.
Problem at line 1 character 1: Stopping. (0% scanned).
I was just hoping someone had an idea why this was wrong. It is production code and won't be changed but it is always a good idea to learn why something should not be written this way.
Thanks.
Is this a Classic ASP script using JScript rather than traditional Javascript?
If so, I'm not sure JSLint is going to work properly unless you strip out the Classic ASP-specific stuff (<% %>
)
JSLint will work fine, but you have to paste in the part that is just JavaScript.
The <% %>
stuff tells the server that the text inside it is a server-side script to run while outputting the page. So just select the stuff inside, the actual JavaScript, and run that against JSLint.
JSLint works with Javascript, and <%
is not part of Javascript. Just remove this token when you run your code through JSLint and you should get more meaningful results.
Looks like you're trying to jun jslint on non-js code is it in a jsp file or something.
精彩评论