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.