-2

我正在尝试使用此功能转到另一个页面

function MButton1Click(event) {
alert("teste2");
window.location("teste.php");
}

但我得到

对象的位置不是函数

4

2 回答 2

2

用这个:

window.location = "teste.php";

您的语法适用于函数..location()但是location是一个对象。

查看window.location 文档

于 2013-07-04T22:36:19.417 回答
0

位置是一个对象。您可以使用其分配替换功能来更改页面:

// Use this if you want the back button to take you to the current page
window.location.assign("teste.php");

// Use this if you want to remove the current page from the browser's history
window.location.replace("teste.php");

您还可以将赋值简写用于assign

window.location = "teste.php";
于 2013-07-04T22:39:33.327 回答