PHP implementation of general alert functions, php general alert functions _ PHP Tutorial

Source: Internet
Author: User
PHP implements General alert functions, and php universal alert functions. PHP: the method for implementing the general alert function. the example in this article describes how php implements the general alert function. Share it with you for your reference. Specifically: functions: methods for implementing general alert functions using PHP, and general alert functions using php

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:

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.

Examples in this article describes how PHP implements General alert functions. Share it with you for your reference. The details are as follows: Function: General mention...

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.