WINDOW event

The window event is a more important event, so I will explain it next.

1. Get the distance of the scroll bar of the page

   What is the scroll bar, that is, when the content of the web page is too much, the scroll wheel controls the up and down display or the left and right display;

< span style="color: #000000;">   add a scroll bar event to the window:

  window.onscroll=function(){};
  Pay attention to when obtaining the scroll bar distance
   Google does not recognize document.documentElement.scrollTop, document.body.scrollTop must be added; that is
  var scrolltop=document.documentElement.scrollTop||document.body.scrollTop;
   Only in this way can it be compatible with various browsers.
  This event is generally used when an event is triggered when the page scrolls to a certain distance,
  For example, the navigation bar of Jingdong:
Share a picture

 and when sliding to the bottom, an event that goes back to the top is launched
Share a picture

Several ways to open a new hyperlink:

1. Replace the current window, you can go back

  html writing:

Effect: share picture  share picture

  JS writing: Replace the current window , You can go back

   Effect: share picture  share picture

2. Replacing the current window can’t go back

  html can’t do it ;

  JS writing method: replace the current window, cannot go back

   Effect: share picture

p>

3. Open in a new window, you can open multiple

  html writing: in a new window Open, you can open multiple

   effects:

  share picture

  JS writing method: Open in a new window, you can open more

   Effect:

Share a picture

4. Open in a new window, only one can be opened

  html writing: new The window is open, only one can be opened

   Effect: share picture< /p>

  JS writing method: A new window opens, only one can be opened p>

   Effect:

Share a picture

Note:

  Open window syntax:
  var newWindow = window.open(url,name,webpage information)
  name page The name cannot be omitted
Window.close() Note that some browsers are not allowed to close themselves
Some well-designed name attributes:
    _self automatically get the name of the current window
not   bla _ nk Empty

   The above operation of only opening one page is brought by the name value, which is similar to taking a name for the previous URL and opening the webpage through the name value

    Share a picture

Leave a Comment

Your email address will not be published.