Blocking html page loading

Source: Internet
Author: User

Blocking html page loading

Add a <body> label

<script type="text/javascript">document.execCommand("stop")</script>

To prevent the interface from loading.


How to Write javascript code to prevent the website from being closed

Onbeforeunload Method

Onbeforeunload and onunload events
Onunload and onbeforeunload are all called during refresh or shutdown. You can use window. onunload in the <script> script to specify them or in <body>. The difference is that onbeforeunload is executed before onunload, which can also stop onunload execution.
Onbeforeunload is also called when the page is refreshed or closed. Onbeforeunload is called when the server is about to read a new page. At this time, it has not started reading; onunload has read the new page to be loaded from the server and is called when the current page is to be replaced. Onunload cannot prevent page updates or closures. Onbeforeunload can be used.

Only onload is executed when the page is loaded.
When the page is closed, run onbeforeunload and then onunload.
When the page is refreshed, execute onbeforeunload first, then onunload, and finally onload.

1. onbeforeunload event:
Note: currently, firefox and IE of the three major browsers support onbeforeunload events, but opera does not.
Usage:
· Object. onbeforeunload = handler
· <Element onbeforeunload = "handler "... > </Element>
Description:
When an event is triggered, a confirmation and cancellation dialog box is displayed. If you are OK, the page is left. If you cancel the event, the page continues to be canceled. Handler can set a return value as the displayed Text of the dialog box.

Triggered on:
· Close the browser window
· When you go to other pages through the address bar or Favorites folder
· Click return, forward, and refresh. When one of the home pages is displayed
· When you click a url to connect to another page
· Call any of the following events: click, document write, document open, document close, window close, window navigate, window NavigateAndFind, location replace, location reload, form submit.
· When you use window open to open a page and pass the window name on this page to the page to open.
· When the location. href value is assigned again.
· When submitting a form with the specified action through the input type = "submit" button.
It can be used in the following elements:
· BODY, FRAMESET, window
Platform support:
IE4 +/Win, Mozilla 1.7a +, Netscape 7.2 +, Firefox0.9 +
Example:
<Html xmlns = "www.w3.org/5o/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title>

How to shield the CSS of the modules called in HTML

1. First find the css file of this module.
2. Find the class name or id that you want to modify.
3. Rename the class name or id of the part to be modified on the current html page.

For example:
A css file is called on the current page. This css file is the default css file used for that module.

<Head>
<Title> change css </title>
<Link rel = "stylesheet" rev = "stylesheet" href = "css/normal.css" type = "text/css" media = "all"/>
</Head>

In this normal.css, the style of a class is defined:

Lookme {width: 300px; height: 10px; background: # ccc ;}

If you want to change the current page, you can directly redefine lookme in the current page, for example:

<Head>
<Title> change css </title>
<Link rel = "stylesheet" rev = "stylesheet" href = "css/normal.css" type = "text/css" media = "all"/>
</Head>
<Style type = "text/css">
Lookme {width: 100px; height: 50px; background: red ;}
</Style>

In this way, you can. The result is displayed on the current page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.