最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery - Unterminated String Constant - Stack Overflow

programmeradmin0浏览0评论

I have a page with jquery on it. It works fine in Firefox, Chrome etc but if I load it in IE, none of the Jquery functions run, and IE's script debugger shows:


Error

A Runtime Error has occurred. Do you wish to Debug?

Line: 269

Error: Unterminated string constant

Yes No

The line in question is in my (unmodified) jquery.js that is causing the error is

style.left = ret || 0;

It also shows:


Error

A Runtime Error has occurred. Do you wish to Debug?

Line: 835

Error: Invalid argument.

Yes No

With the line in question being:

ret = style.pixelLeft + "px";

Any ideas?

EDIT:

Seems I may have been looking in the wrong place for the error. If I take this out, it works:

    $(".middlebox").children("p").hide();
    $(".middlebox").addClass("middlebox_closed", "fast");

I have a page with jquery on it. It works fine in Firefox, Chrome etc but if I load it in IE, none of the Jquery functions run, and IE's script debugger shows:


Error

A Runtime Error has occurred. Do you wish to Debug?

Line: 269

Error: Unterminated string constant

Yes No

The line in question is in my (unmodified) jquery.js that is causing the error is

style.left = ret || 0;

It also shows:


Error

A Runtime Error has occurred. Do you wish to Debug?

Line: 835

Error: Invalid argument.

Yes No

With the line in question being:

ret = style.pixelLeft + "px";

Any ideas?

EDIT:

Seems I may have been looking in the wrong place for the error. If I take this out, it works:

    $(".middlebox").children("p").hide();
    $(".middlebox").addClass("middlebox_closed", "fast");
Share Improve this question edited Sep 16, 2009 at 9:55 Oli asked Sep 16, 2009 at 9:39 OliOli 1,0037 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

The error is not necessarily in the jQuery code, but the argument value being passed as a parameter into a function in jQuery i.e. the step before.

EDIT:

This line is incorrect

$(".middlebox").addClass("middlebox_closed", "fast");

addClass() does not take 2 arguments, just one which is a string for the class that you wish to add. Change it to

$(".middlebox").addClass("middlebox_closed");

and it will work. Or maybe you wanted to add 2 classes, in which case this will work too

$(".middlebox").addClass("middlebox_closed").addClass("fast");
// or this for brevity
$(".middlebox").addClass("middlebox_closed fast");
  1. (maybe) Try using style.left instead of pixelLeft Also check that style is initialised properly.
  2. What are you trying to achieve by this line? style.left = ret || 0; Maybe you wanted something like style.left = parseInt(ret)
发布评论

评论列表(0)

  1. 暂无评论