boris.fu
boris.fu

Reputation: 1

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

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);

Track the error log to see, seems "temp.add(new Option('111', '222'));"; statement is not work under getEval command. the error show:

"Access to property denied"

Beside context different from these two commands. Why?

Upvotes: 0

Views: 574

Answers (1)

Diode
Diode

Reputation: 25145

Runscript runs the script in the same scope, but GetEval takes str and tries to run it in a different scope. If the issue is with temp.add statement, I guess it is because definition of Option is not coming in the scope when executed by GetEval .

Upvotes: 2

Related Questions