[英]Why is this function throwing a 'strict' error in javascript?
我想要一個從頁面加載時開始調用的函數,然后該函數將偵聽器添加到頁面上的div標記中,偵聽器會將我的javascript文件中的全局變量更改為true或false,但是我可以這樣做是因為我在嘗試執行該函數時收到關於函數嚴格的錯誤。
瀏覽器:Chrome
錯誤:
TypeError:在嚴格模式函數或用於調用它們的參數對象上,可能無法訪問“ caller”,“ callee”和“ arguments”屬性
查看代碼:
<script>
$(document).ready(function () {
var imgs = document.querySelectorAll(".cut-images");
[].forEach.call(imgs, function (img) {
img.addEventListener("dragstart", dragStart, false);
img.addEventListener("dragend", dragEnd, false);
});
});
使用Javascript:
var isOnDiv = false;
function dragStart(e) {
this.style.opacity = "0.4";
document.getElementById("chuckImage").addEventListener("mouseenter", function () { isOnDiv = true; });
document.getElementById("chuckImage").addEventListener("mouseout", function () { isOnDiv = false; });
e.dataTransfer.effectAllowed = "move";
}
function dragEnd(e) {
if (isOnDiv === true)
alert("ding");
this.style.opacity = "1.0";
}
有誰知道為什么我的函數可能會拋出此錯誤?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.