javascript获取难以索引的对象
1.Eval
function simpleSwap()
{
var the_image = prompt("change parrot or cheese","");
var the_image_name = "window.document." + the_image;
var the_image_object = eval(the_image_name);
the_image_object.src = "ant.gif";
}
2.名称索引{
var the_image = prompt("change parrot or cheese","");
var the_image_name = "window.document." + the_image;
var the_image_object = eval(the_image_name);
the_image_object.src = "ant.gif";
}
function simpleSwap()
{
var the_image = prompt("change parrot or cheese","");
window.document.images[the_image].src = "ant.gif";
}
{
var the_image = prompt("change parrot or cheese","");
window.document.images[the_image].src = "ant.gif";
}