"未捕获的SyntaxError:意外的令牌(“,但没有错误 [英] "Uncaught SyntaxError: Unexpected token (" but there is no error
问题描述
我正在编写一个简单的用户脚本,该脚本将为Chromium浏览器提供Windows中的退格按钮导航控件(特别是针对Linux用户)。
I'm authoring a simple userscript that will give the backspace button navigation control like in windows (specifically this is for linux users) for Chromium browser.
此脚本正常工作,然后我对其进行了一些更改(非常简单的内容,注释,制表,使其美观),以及现在我收到此错误:
This script was working, then I made a few alterations to it (very simple stuff, commenting, tabbing, making it pretty), and now i'm getting this error:
未捕获的语法错误:意外令牌(
Uncaught SyntaxError: Unexpected token (
在此行
document.head.appendChild(script);
脚本位于这里-我正在拔头发试图解决这个问题。
The script is located here - i'm pulling out my hair trying to figure this out.
脚本确实仅适用于铬,因为ff为您提供了启用此功能的配置选项。.
-Chromium 15.0.874.106(Developer Build 107270)Ubuntu 11.10
The script really only applies to chromium as ff gives you a configuration option to enable this functionality.. - Chromium 15.0.874.106 (Developer Build 107270) Ubuntu 11.10
编辑 如果有人可以告诉我为什么这行不通,那就太好了
EmbedCodeOnPage("(function() {" + fn.toString() + "})();"); // fails
EmbedCodeOnPage("(" + fn.toString() + ")()"); // works.
推荐答案
因为您只是加入了匿名函数而没有执行它
because you are just dropping in an anonymous function and not executing it
更改第46行并添加()
change line 46 and add ()
这篇关于"未捕获的SyntaxError:意外的令牌(“,但没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!