Current location - Music Encyclopedia - Chinese History - Js modifies browser history
Js modifies browser history
1.js, how to change the previous page to another page JS does not change the browsing history url, and obtains the url address from the previous page. You can use window.location.replace (URL); To reset the browsing history,

Window.location.replace does not save the URL before the browser jumps, so pressing Enter will be invalid;

Example:

There are three jsp pages (1.jsp, 2.jsp, 3.jsp), and the default entry is 1. JSP。 When I entered 2.jsp, I used window.location.replace ("3. JSP ") in JSP. Use window.location.href ("3.jsp"); "); There is no difference with the user interface, but when the 3.jsp page has a "back" button, call window.history.go (-1); wondow . history . back(); Method, click the back button to return to the 2.jsp page, and the difference will come out when using the window. Location. Replace ("3. JSP”); If you are connected to 3.jsp page, call window.history.go (-1) in 3.jsp page; wondow . history . back(); The method is not easy to use. When using window.location.href("3.jsp "),1.jsp will be returned; "); If you are connected to 3.jsp page, call window.history.go (-1) in 3.jsp page; wondow . history . back(); This method is easy to use and will be returned to 2.jsp. Because window.location.replace ("3.jsp"); Is a jump that does not send a request to the server, while window. history.go (-1); wondow . history . back(); The method decides which page to jump to according to the request recorded by the server, so it will jump to the system default page1.jsp.window.location.href ("3.jsp"); Is a jump to send a request to the server, window.history.go (-1); wondow . history . back(); The method is to decide which page to jump to according to the request recorded by the server, so that you can return to 2.jsp.

2.2. How does 2.2.javascript set the history for the navigation in the form?

History, China's "history"

Historical objects are attributes of window objects.

Browsers can usually use the browser's forward and backward buttons to access the pages they have visited. The historical object of JavaScript records the pages visited by users, which can realize the navigation function similar to that of a browser.

You can use the back function to go back one page and the forward function to go forward one page. You can also use the length property to check the number of pages stored in the history object.

Historical objective function

JavaScript history.go () function

Description: Specify the number of pages forward or backward.

JavaScript history.back () function

Description: Take a page back.

JavaScript history.forward () function

Description: Go forward one page.

Historical object attribute

JavaScript length property-how many URLs are cached in the-history object?

example

Historical length;

3. How to modify the browser's JavaScript options in IE8 (I don't know if IE6 and IE7 are the same, but they are basically the same) 1. If you don't know how to enter "Inter Options", open IE, press and hold the "Alt" key on the keyboard (next to the space bar) and then you will see a menu bar above or below the "Address bar", which contains: file, edit.

Click "Tools", and then click "Inter Option" in the pop-up drop-down menu. 2. After entering "International Options", you will see a big box. Look at the top and you will find several labels: General, Security, Privacy and Content. Click "Security" and you will see that the following contents have changed. 3. After entering the "Security" tab through the previous step, first make sure that the "Inter" item (namely "Earth") is selected, and then turn your attention to the bottom.

At the bottom, there are three buttons: OK, Cancel and Apply. On them, you can find a button called "Custom Level" and click it.

4. Another box pops up, and you can see a bunch of settings. Slowly drag the vertical scroll bar down until you find the Script option, which should be above and below the ActiveX option.

You have to be patient in this step, you may not find it all at once. 5. Drag the scroll bar down a little, and you will see a project named "Active Script". There is a radio box below with three choices: disable, enable and prompt.

Click "Enable". Then click OK at the bottom of the whole box.

Then click OK in the Inter Options box. I think so. If you still don't understand anything, please ask it in the supplementary question. If you are satisfied, you should give points. Thank you.

4. There are two ways to modify the browser address with JS.

1. Write the silent jump to page A, and page A will jump to page C immediately after page B pops up.

Page code:

& amplt; a href = " # " onclick = " open new " & amp; gt; Hyperlinks on Web pages &; lt; /a & amp; gt;

& amplt; Script type = text/JavaScript &; gt;

Function opennew{

window . open(" " target = " _ blank " & amp; gt; Hyperlinks on Web pages &; lt; /a & amp; gt;

B page code:

& amplt; Script type = text/JavaScript &; gt;

Function opennew{

window . opener . location =“”; //A page jumps to Google.

}

& amplt; /script >

& amplt; body onload = " open new " & amp; gt;

This is to execute the opennew () method after the B page is loaded, and let the A page jump. You can trigger events elsewhere in the B page and call the opennew () method.

& amplt; /body & amp; gt;