Javascript about window focus

Source: Internet
Author: User

Sometimes you can write a webpage to execute some tasks, which are long-lived tasks. Javascript will automatically execute the steps. In normal times, I open the tasks directly and let them run them by myself, but sometimes it will stop with an error, but I don't know, it is a waste of waiting time, so I want to know how to notify me when I don't see that page. I went to the Internet to find JavaScript, and a function was available.

 

Window. Focus ();

 

This function, when you do not view it on this page, if Javascript triggers this event, it will flash the focus in the Windows taskbar, as if there is a message from QQ, it will flash in the taskbar.

 

By the way, write down the JavaScript code for automatically scheduled tasks. Some PHP code is contained in the middle.

 

<Script language = "JavaScript">
<! --
VaR go_next = true;
Function stop (){
Go_next = false;
}
// -->
</SCRIPT>
<A href = '? Page = <? = $ Page + 1?> '> Next page </a> <br> next page 2 seconds later
<Input type = "button" value = "stop" onclick = "Stop ()">
<Script language = "JavaScript">
<! --
<? If ($ oneok) {?>
SetTimeout ("next_page ()", 2000 );
<? }?>
Function next_page (){
If (go_next) location. href = "? Page = <? = $ Page + 1?> ";
}

// -->
</SCRIPT>

Related Article

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.