简体   繁体   English

为什么会出现错误“错误未定义'http…'不是函数”?

[英]Why does I get the error “error undefine 'http…' is not a function”?

<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");
   }

Hello guys i tested this code on my local server and it can work but however i tested this on the mobile server. 大家好,我在本地服务器上测试了此代码,它可以工作,但是我在移动服务器上测试了此代码。 It throws back an error undefine 'http....' is not a function 它抛出错误,未定义“ http ....”不是函数

window.location.href is a string, not a function. window.location.href是一个字符串,而不是一个函数。

Assign a value to it with = =为其赋值

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

Although, in this case, you shouldn't. 尽管在这种情况下,您不应该这样做。 There is no need to involve JavaScript in this. 无需在其中涉及JavaScript。

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

Window.location accepts a string. Window.location接受一个字符串。 as you are making as a function , check the MDN for documentation Window.location 在执行功能时,请检查MDN以获取文档Window.location

function proceed()       
{
   window.location.href="CreditCard.aspx"; // change like this 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM