为什么我收到错误“错误未定义'http..'不是一个函数”

Why does I get the error "error undefine 'http....' is not a function"?

本文关键字:错误 一个 函数 错误未定义 未定义 http 为什么      更新时间:2023-09-26
<div class="ui-block-b"><a href="#" data-theme="b" data-role="button" onclick="proceed()" >Proceed</a></div>   

   function proceed() 
   {
       window.location.href("CreditCard.aspx");
   }

大家好,我在本地服务器上测试了此代码,它可以工作,但是我在移动服务器上对其进行了测试。它会抛出一个错误,取消定义"http..."。不是函数

window.location.href是一个字符串,而不是一个函数。

使用=为其赋值

function proceed() {
   location.href = "CreditCard.aspx";
}

虽然,在这种情况下,你不应该。没有必要让 JavaScript 参与其中。

<div class="ui-block-b">
    <a href="CreditCard.aspx" data-theme="b" data-role="button">
        Proceed
    </a>
</div>   

Window.location 接受一个字符串。 当你作为一个函数制作时,检查MDN的文档Window.location

function proceed()       
{
   window.location.href="CreditCard.aspx"; // change like this 
}
相关文章: