Javascript; Sending user to another page

前端 未结 6 2091
情深已故
情深已故 2021-02-19 01:07

I am trying to send a user to another page using a Javascript Function:


<         


        
6条回答
  •  天命终不由人
    2021-02-19 02:08

    your code got messed up, but if I got it right you can use the following:

    location.href = 'http://www.google.com';
    or
    location.href = 'myrelativepage.php';
    

    Good luck!

    But I must say to you,

    1. Javascript can be turned off, so your function won't work.

    Other option is to do this by code:

    PHP: header('Location: index.php');

    C#: Response.Redirect("yourpage.aspx");

    Java: response.sendRedirect("http://www.google.com");

    Note:

    1. All of those redirects must be placed before any outputs to the client ok?

提交回复
热议问题