为什么相同的javascript可以使用runscript命令运行,但不能在RC中的getEval中运行

Why the same javascript can run with runscript command, but not in getEval in RC

本文关键字:运行 但不能 中的 getEval RC 命令 javascript 可以使 runscript 为什么      更新时间:2023-09-26
string str = "var temp = window.document.getElementById('ctl00_PageContentPlaceHolder_Manager');temp.style.display = 'inline';";
str += "temp.add(new Option('111', '222'));";
str += "temp.nextSibling.childNodes[1].innerHTML = '<I></I><SPAN></SPAN>Edit Manager Contact';";
//selenium.RunScript(str);
selenium.GetEval(str);

跟踪错误日志以查看,似乎"temp.add(new Option('111', '222'));";语句在getEval命令下不起作用。 错误显示:

"拒绝进入财产">

除了与这两个命令不同的上下文。为什么?

Runscript在同一作用域中运行脚本,但GetEval str并尝试在不同的作用域中运行它。如果问题出在temp.add语句上,我想这是因为Option的定义在由GetEval执行时不在范围内。

相关文章: