我正在使用经典 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"
value on selected index of selObj = "edit_details.asp?make=ML&n=&r=DA61CHH&c=Hope Ready Mixed Concrete Ltd - 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');
关于evalparent.location 的 JavaScript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24702497/