SoFunction
Updated on 2025-03-02

Several common ways to implement page jump in JavaScript

This article describes several common ways to implement page redirection in JavaScript. Share it for your reference, as follows:

The first type:

<script language="javascript" type="text/javascript"> 
    ="?backurl="+; 
</script> 

The second type:

&lt;script language="javascript"&gt;
    alert("return");
    (-1);
&lt;/script&gt; 

The third type:

<script language="javascript">
    ("");
</script>

The fourth type:

<script language="JavaScript">
    ='';
</script>

The fifth type:

&lt;script language="javascript"&gt;
    alert("Illegal access!");
    ='';
&lt;/script&gt;

Select box pops up in javascript to jump to other pages

&lt;script language="javascript"&gt;
&lt;!--
function logout()...{
if (confirm("Are you sure you want to cancel your identity? Yes - select OK, No - select Cancel"))...{
="?act=logout"
}
}
--&gt;
&lt;/script&gt;

A prompt box pops up in javascript and jumps to other pages

&lt;script language="javascript"&gt;
&lt;!--
function logout()...{
alert("Are you sure you want to cancel your identity?");
="?act=logout"
}
--&gt;
&lt;/script&gt;

Supplement: What is the difference between =""; and ("");?

Both of these can make the web page direct to a URL, so what's the difference? For example, it can bring parameters, but not parameters.
Replace? Or Reload()?
It seems there is no difference, right? Haven't tried it
 
replace(), reload() is to reload this page, and replace() can lead to another URL
 
Give you an example:

We now have 3 pages (, , ).
The page is opened by default, and then turn to the page through a link in the page.

Now, I use (""); and use (""); in the page respectively.

From the user interface, there is no difference, but now the page has a "return" button.
use("");

When entering the page, the call (-1);(); when entering the page, if you click the "return" button to return to the page,
If you use (""); to enter the page,
The call (-1);(); method in the page is not easy to use and will return to.
 
Because (""); will not send a request to the server and jump, and the (-1);(); method determines which page to jump to based on the request recorded by the server, so it will jump to the system default page.

(""); is a jump to send a request to the server. (-1);(); method determines which page to jump to based on the request recorded by the server, so you can return to it.

I hope this article will be helpful to everyone's JavaScript programming.