这是我的小提琴,http://jsfiddle.net/4vaxE/35/
它在我的小提琴中运作良好.
但是,当我将它转移到Dreamweaver时,它无法工作.我在编码中发现了这两个错误.
我之前读过有关这两个错误的文章,并尝试按照提供的方法解决,但是,它仍然无法正常工作,我该如何解决?
这是我在Dreamweaver中的完整编码
<body>
<div class="buttons" style="background-color: rgba(0,0,0,.8);">
<a class="button" id="showdiv1">Div 1</a>
<a class="button" id="showdiv2">Div 2</a>
<a class="button" id="showdiv3">Div 3</a>
<a class="button" id="showdiv4">Div 4</a>
</div>
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
<div id="div4">4</div>
</div>
<script language="JavaScript" type="text/javascript" script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script language="JavaScript" type="text/javascript">
var selectedEffect="explode";
var options = { percent: 100 };
$('#showdiv1').click(function () {
$('div[id^=div]').hide();
$('#div1').show( selectedEffect, options, 500, callback );
});
$('#showdiv2').click(function () {
$('div[id^=div]').hide();
$('#div2').show( selectedEffect, options, 500, callback );
});
$('#showdiv3').click(function …Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery.这是我在主页上的编码:
<script type="text/javascript" src="script.js">
</script>
Run Code Online (Sandbox Code Playgroud)
我的script.js是:
$(document).ready(function(){
$("#title").click(function () {
alert("Works!");
});
});
Run Code Online (Sandbox Code Playgroud)
我的完整编码可以在这里找到:http://pastie.org/8676656.
在浏览器上使用工具,我在我的javascript代码中发现了一个错误:
ReferenceError: Can't find variable: $
Run Code Online (Sandbox Code Playgroud)
在线:
$(document).ready(function() {
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
我正在尝试删除监听器。在控制台中,下面的代码正在运行。当我在 Chrome 扩展中使用代码时,我得到:“Uncaught ReferenceError:getEventListeners 未定义”。为什么会出现这种情况?是否有与“getEventListeners”功能等效的函数?
document.addEventListener('click', fireContentLoadedEvent, false);
function fireContentLoadedEvent () {
console.log ("DOMContentLoaded");
for (let i = 0; i < document.getElementsByClassName("someClass").length; i++) {
plusButton = document.getElementsByClassName("someClass")[i]
if ( getEventListeners(plusButton)["click"].length > 1) {
plusButton.removeEventListener("click", getEventListeners(plusButton).click[1].listener);
}
}
}
Run Code Online (Sandbox Code Playgroud) javascript google-chrome google-chrome-extension referenceerror google-chrome-devtools
我知道FileReader对象在Safari 5.0.5中不可用.我有一个使用它的脚本,并认为我只能检测对象是否存在以运行一些备用代码,如此处所示,
http://www.quirksmode.org/js/support.html
所以我的代码是,
if( FileReader )
{
//do this
}else{
//the browser doesn't support the FileReader Object, so do this
}
Run Code Online (Sandbox Code Playgroud)
问题是,我在Safari中测试过,一旦它命中if语句,我就会收到此错误并且脚本停止运行.
ReferenceError:找不到变量:FileReader
那显然那不是处理它的最好方法吗?知道为什么这不起作用吗?
我在以下用户脚本代码中得到一个ReferenceError:
// ==UserScript==
// @name ...
// @namespace ...
// @description ...
// @include ...
// @grant GM_xmlhttpRequest
// ==/UserScript==
console.log(GM_info);
try
{
console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState);
}
catch (e)
{
console.log(e);
}
...
Run Code Online (Sandbox Code Playgroud)
它首先GM_info成功记录,然后记录ReferenceError.(我正在使用Firefox/Firebug.)
ReferenceError:未定义GM_xmlhttpRequest
为什么我会收到此错误?
在Chrome和Firefox中
typeof foo
Run Code Online (Sandbox Code Playgroud)
评估为'undefined'.
但
typeof (function() { return foo; })()
Run Code Online (Sandbox Code Playgroud)
抛出错误:
ReferenceError: foo is not defined
Run Code Online (Sandbox Code Playgroud)
这破坏了我对表达式可疑性的概念!到现在为止,我知道没有条件,这foo和(function() { return foo; })()是不一样的.
这是标准行为吗?如果是这样,引用ECMAScript标准的相关部分会很有帮助.
编辑:
另一个例子:
typeof (foo)
typeof (foo + 0)
Run Code Online (Sandbox Code Playgroud)
我希望(foo)并(foo + 0)抛出一个错误.
但第一个没有错误; 第二个.
我在尝试创建JQuery图像滑块时收到此错误消息.
未捕获的ReferenceError:$未定义
这是我的新编码(请注意,我已将脚本移至页面,这是adobe建议的.):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Green Cold-Formed Steel | Home</title>
<style type="text/css">
body,td,th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 10px;
color: #000;
text-align: left;
}
body {
background-color: #999;
}
a:link {
color: #999;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #060;
}
a:hover {
text-decoration: underline;
color: #FFF;
}
a:active {
text-decoration: none;
}
h1 {
font-size: 14px;
color: #060;
}
h2 {
font-size: 12px;
color: #999;
}
h3 {
font-size: 9px;
color: #FFF; …Run Code Online (Sandbox Code Playgroud) 我有一个textarea,用户可以输入javascript代码,按下按钮后将传递给eval().
当用户输入如下内容时,我无法捕获referenceError:
var myName = Maria;
Run Code Online (Sandbox Code Playgroud)
代替
var myName = "Maria";
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间!
在尝试调试一些有问题的JavaScript时,我发现在源文件中看起来像一个明显错误的行:
false++;
Run Code Online (Sandbox Code Playgroud)
我不明白的是为什么这个语句在所有浏览器中表现不同.
设计是否允许不同的浏览器以不同的方式处理相同的破解JavaScript?
我知道错误是什么以及如何解决它,但至少不应该规范的错误类型?
什么是两者之间的差异
TypeError: ... is undefined
Run Code Online (Sandbox Code Playgroud)
和
ReferenceError: ... is not defined
Run Code Online (Sandbox Code Playgroud)
?
referenceerror ×10
javascript ×9
jquery ×3
expression ×1
filereader ×1
firefox ×1
greasemonkey ×1
html ×1
image ×1
jquery-ui ×1
safari ×1
syntax-error ×1
typeerror ×1
typeof ×1