gpt4 book ai didi

JavaScript 评估问题

转载 作者:行者123 更新时间:2023-11-28 21:19:21 25 4
gpt4 key购买 nike

我有一个正在解析 xml 的函数,其中包含 javascript 函数调用。一个例子是:

eval(getElementText(PropValue[0])); 

getElementText(PropValue[0] = top.hidePopWin()

我跟踪了这​​个调用直到 hidePopWin 函数,并观察了它从函数顶部到函数底部的完成过程。

一切看起来都按顺序进行,但是我在 Firefox 中遇到了这个讨厌的错误:top is null正如您可能已经猜到的那样,hidePopWin 会关闭当前显示的弹出窗口。

因此,调用了 hidePopWin 并且它运行得很好(实际上弹出窗口确实关闭了),但之后就是问题了。它不会进入下一步。我在 Firefox (firebug) 中收到 top is null 消息,然后它就停止了。

我需要提到的唯一一件事是整个过程从双击事件(遗留代码)开始。还有一个会触发的单击事件。起初我以为这可能是问题所在,但是,我取出了对 onclick 事件的引用,但仍然收到相同的消息。

所以我认为这与 eval 有关。陈述。为了获得更多信息,我在 eval 上方放置了一个 console.log("1")语句和 eval 下面的 console.log("2") 。打印“1”,不打印“2”。

有人对可能出现的问题有任何想法吗?

更新:

 if(getElementText(PropValue[0]) == "top.hidePopWin();"){
console.log('here');
top.hidePopWin();
console.log('end');
}else{
console.log(getElementText(PropValue[0]));
eval(getElementText(PropValue[0]));
}

好的,我尝试了上面的方法...我看到了“here”语句,但它仍然显示top is null。 “结束”语句永远不会打印。当我单击顶部 is null in FF 时,它会突出显示 eval 语句???所以我不知道到底发生了什么。

最佳答案

不,但是你可以更改代码以直接执行 eval 和 test 之外的代码吗?

所以,改变,eval(getElementText(PropValue[0])); 到 顶部.hidePopWin();

看看你是否遇到同样的错误。

关于JavaScript 评估问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6795896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com