PHP implements General alert functions. PHP: how to implement general alert functions this article mainly introduces PHP's method for implementing general alert functions. The example shows how to implement prompt information for php custom alert functions, very practical PHP method for implementing general alert functions
This article mainly introduces the PHP method for implementing general alert functions. The example analyzes the tips of php custom alert functions for implementing prompt information, which is very useful. For more information, see
This example describes how to implement a common alert function in PHP. 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:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Function Alert ($ Str, $ Typ = "back", $ TopWindow = "", $ Tim = 100 ){ Echo "script". chr (10 ); If (! Empty ($ Str )){ Echo "alert (\" Warning: \ 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 refreshing the setTimeout Echo "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.
This article describes how to implement the common alert function in PHP. The example analyzes the tips for implementing the php custom alert function, which is very practical...