简体   繁体   中英

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

window.location.href is a string, not a function.

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.

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

Window.location accepts a string. as you are making as a function , check the MDN for documentation Window.location

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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