PHP implementation of general alert functions

Source: Internet
Author: User
This article mainly introduces the PHP method for implementing general alert functions. The example analyzes the php custom alert function implementation tips, which is of great practical value, for more information about how to implement the common alert function in PHP, see the following example. Share it with you for your reference. The details are as follows:

Function: common prompt
Parameter: prompt message, type or website, window name or function name, delay in milliseconds
Alert ("", "function", "close2", 300 );

The code is as follows:

Function Alert ($ Str, $ Typ = "back", $ TopWindow = "", $ Tim = 100) {echo "script". chr (10); if (! Empty ($ Str) {echo "alert (\" Warning :\\ n \ n {$ Str} \ n \");". chr (10);} echo "function _ r_r _ () {"; $ WinName = (! Empty ($ TopWindow ))? "Top": "self"; switch (StrToLower ($ Typ) {case "#": break; case "back": echo $ WinName. ". history. go (-1 );". chr (10); break; case "reload": echo $ WinName. ". window. location. reload ();". chr (10); break; case "close": echo "window. opener = null; window. close ();". chr (10); break; case "function": echo "var _ T = new function ('return {$ TopWindow} ') (); _ T ();". chr (10); break; // Die (); Default: if ($ Typ! = "") {// Echo "window. {$ WinName }. location. href = '{$ Typ}'; "; echo" window. {$ WinName }. location = ('{$ Typ}'); ";}} echo "}". chr (10); // to prevent Firefox from skipping the setTimeout echo line "if (setTimeout (\" _ r_r _()\",". $ Tim. ") = 2) {_ r_r _ () ;}"; if ($ Tim = 100) {echo" _ r_r _();". chr (10);} else {echo "setTimeout (\" _ r_r _()\",". $ Tim. ");". chr (10);} echo "script". chr (10); Exit ();}

I hope this article will help you with php programming.

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.