PHP how to write similar to JS in alert () Prompt box

Source: Internet
Author: User
This article mainly introduces PHP implementation similar to JS in the alert () prompt box function, very practical, here is recommended to everyone, there is a need for small partners to reference, I hope you can like.

Mainly used to add judgment hints, jumps, returns, refreshes.

The code is as follows:

/** * js prompt jump * @param $tip pop-up window prompt information (no prompt for null) * @param $type set Type close = Off, back= return , refresh= prompt reload, jump hint and skip URL * @param $url jump URL */function alert ($tip = "", $type = "", $url = "") {$js = "<scrip    T> "; if ($tip) $js. = "alert ('". $tip.    "');";            Switch ($type) {case "close"://Closes the page $js. = "Window.close ();";        Break            Case ' back '://return $JS. = "History.back (-1);";        Break            Case "Refresh"://Refresh $js. = "Parent.location.reload ();";        Break Case "Top"://Frame exits if ($url) $js. = "top.location.href=". $url.            "';";        Break Case "jumping"://Jump if ($url) $js. = "window.location.href=". $url.            "';";        Break    Default:break;    } $js. = "</script>";    Echo $js;    if ($type) {exit (); }}

Summary : The above is the entire content of this article, I hope to be able to help you learn.

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.