JavaScript error for eval parent.location
JavaScript error for eval parent.location
我在经典ASP工作。我正在使用的代码(不是我的代码)是很久以前写的,甚至可能早在Firefox和Chrome出现之前。
无论如何,有以下JavaScript函数:
function MM_jumpMenu(targ, selObj, restore) {
eval(targ + ".location ='" + selObj.options[selObj.selectedIndex].getAttribute('value') + "'");
if (restore)
{
selObj.selectedIndex=0;
}
}
那个代码突然停止工作了,我想找出原因。在Chrome中,它给了我错误:
SyntaxError: Unexpected identifier
当我尝试运行代码时,传入的参数如下:
targ = "parent"
对selObj所选索引的值 = "edit_details.asp?make=ML&n=&r=DA61CHH&c=Hope预混合混凝土有限公司- CHY LCV's&cus=HOPEAG02&type=&inc=&id=&fw=&cusid=HOPE03"
restore = 0
假设代码是专门为IE 6/7编写的,我们正在努力标准化,使其适用于所有浏览器
eval
是邪恶的!!不要用它!
window[targ].location = selObj.options[selObj.selectedIndex].getAttribute('value');
url中有一个未转义的单引号。
CHY LCV's&
埃斯佩斯:
CHY LCV''s&
但实际上,这段代码太可怕了,如果可以的话你应该重写一遍。
"value on selected index of selObj ":带有撇号。你需要转义
相关文章:
- 正在使用$location.path(.)路由ng视图
- window.location替换并传递URL历史记录条目中的变量
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- location.reload(true)崩溃浏览器选项卡
- window.location使用jquery mobile实现chrome跳转
- Windows.Open 在 window.Location 工作时不起作用
- 我可以使用location.href为变量生成url吗
- jQuery parent() in table
- 如何将所有作业自定义到window.location.href
- window.location未刷新到现有URL
- 依次调用location.reload()和location.assign()
- 如果window.location.href.indexOf('player=1')添加样式
- 在$state.go之后执行$window.location.reload(true)
- 脏表单 - 如何忽略在parent.window.location.href上弹出的脏表单
- parent.window.location.pathname 返回未定义
- 阻止parent.window.opener.location中的JavaScript
- What is parent.result.location
- JavaScript error for eval parent.location
- window.parent.postMessage and window.location.hostname for t
- window.parent.location.replace(document.URLUnencoded) in asp