Home > OS >  Js jump code page
Js jump code page

Time:11-18

1. In the original form directly jump with
Window. The location. Href="https://bbs.csdn.net/topics/" all you have to jump page;
2, open the page in a new form:
Window. The open (' all you have to jump page ');

Window. The history. The back (1); Return to previous page


3, some use
Push button:
Link type: & lt; A href="javascript: history. The go (1)" & gt; Return to previous page & lt;/a>
Return to previous page & lt;/a>
Jump straight type:
<script> Window. The location. Href='https://bbs.csdn.net/topics/connection address; </script>
Open a new window:




<script>
Window. The open

(' page. HTML ', 'newwindow', 'height=100, width=400, top=0, left=0, the toolbar=no, menubar=no, scrollbars=no,

The resizable=no, location=no, status=no ')
Write a line
-->
</script>

Script runs after page. HTML will open in a new window newwindow, 100 wide, high was $400, from the top of screen 0 pixel, screen left 0 pixel, no work

Article, no bar, no scroll bar, do not adjust the size, no address bar, status bar, please contrast,
The case for the commonly used several parameters involved, in addition there are many other parameters, see four,

Four, the parameter
Also can use 1/0 of yes/no; Pixel value for a specific value, the unit pixel,

Parameter | | value scope description

AlwaysLowered | yes/no | specified window hidden in all the window after
AlwaysRaised | yes/no | specified window suspension on all Windows
Whether depended | yes/no | and parent window closed at the same time
Directories | yes/no | Nav2 directory and 3 bar is visible
Height | pixel value | window height
Hotkeys | yes/no | in the menu bar of the window set safety exit hotkey
InnerHeight | pixel value | window pixels height of the document
InnerWidth | pixel value | the pixel width of the window in the document
The location | yes/no | location bar is visible
Whether the menubar | yes/no | menu bar visible
OuterHeight | pixel value | Settings window (including mine) pixel height
OuterWidth | pixel value | the pixel width of setting window (including mine)
Whether the resizable | yes/no | window size can be adjusted
ScreenX | pixel value | window from the left border of screen pixels length
ScreenY | pixel value | window from the boundary pixels on the screen length
Scrollbars | yes/no | window can have a scroll bar
Titlebar | yes/no | window title bar is visible
The toolbar | yes/no | window toolbar is visible
The pixel Width | pixel value | window Width
Z - look | yes/no | whether the window is activated after the float above other Windows

=====================================================

Pop-up window [1, the most basic code]
Actually the code is very simple:




<script LANGUAGE="javascript" & gt;
Window. The open (' page. HTML)
-->
</script>
Because is a javascripts code, so they should be given & lt; SCRIPT LANGUAGE="javascript" & gt; The labels and & lt;/script> Between

, & lt; ! - and - & gt; Is, for some low version of the browser works in these old browsers will not displayed in the tag code as text, to raise

Into the good habit,
Window. The open (' page. HTML) is used to control the new popup Windows page. The HTML, if page. HTML is not with the main Window in the same directory,

Should specify path, in front of the absolute path (HTTP) and relative path (../), with single and double quotes can be, just don't mix,
This code is able to add HTML anywhere, & lt; head> And & lt;/head> Can, & lt; body> Between & lt;/body> Can also, the sooner ryoma perform

, especially long page code, and want to make the page pops up will try to put forward early,

[2, after setting the pop-up window]

Besides said pop-up window set below, as long as the code to add a few things up again,
We customize the appearance of the pop-up window, the size, the position of the pop-up to adapt to the specific situation of the page,




<script LANGUAGE="javascript" & gt;
Window. The open (' page. HTML ', 'newwindow', 'height=100, width=400, top=0, left=0, the toolbar=no,

The menubar=no, scrollbars=no, the resizable=no, location=no, status=no ')
Write a line
-->
</script>
Parameter interpretation:
<script LANGUAGE="javascript" & gt; Js script;
Window. The open pop-up window command;
'page. HTML pop-up window file name;
The name of "newwindow" pop-up window (not the file name), not a must, available empty 'instead of;
Height=100 window height;
Width=400 window width;
Top=0 window distance at the top of the screen pixel values;
Left=0 window distance to the left of the screen pixel values;

Width=250, the toolbar=no, scrollbars="+ scroll +", menubar=no ");
Write a line
OpenWindow. Document. Write (" & lt; TITLE> Example & lt;/TITLE>" )
OpenWindow. Document. Write (" & lt; BODY BGCOLOR=# ffffff>" )
OpenWindow. Document. Write (" & lt; H1 & gt; Hello! OpenWindow. Document. Write (" New window the opened!" )
OpenWindow. Document. Write (" & lt;/BODY>" )
OpenWindow. Document. Write (" & lt;/HTML>" )
OpenWindow. Document. The close ()}
</script>

<body>



See OpenWindow. Document. The write () inside of the code is not standard HTML? As long as according to the format write more lines can, must pay attention to more than a label or a tag will appear less mistakes, remember to use OpenWindow. The document. The close () the end ah,

[9, the ultimate application -- the Cookie of the pop-up window control]
Recall that the popup window is cool, but there is a little small problems (immersed in joy, must not found?) Such as you will need the above script in a frequent (for example) home page after page, so each time to refresh the page, the window will pop up once, very annoying? : - (have a solution? Yes! ; -) Follow me. We use cookies to control it is ok, first of all, to add the following code to the main page of HTML & lt; HEAD> Area:
<script>
The function openwin ()
{window. The open (" page. The HTML ", ""," width=200, height=200 ")}
The function get_cookie (Name)
{var search=Name + "="
Var returnvaluehttps://bbs.csdn.net/topics/="";
If (document. Cookies. Length & gt; 0 {
Offset=document. Cookies. IndexOf (search)
If (offset!=1) {
Offset +=search. Length
End=document. Cookies. IndexOf (";" , offset);
If (end==1)
End=document. Cookies. Length;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related