php简单封装了一些常用JS操作
在web编程中大家应该会经常用到一些常用js操作,例如 alert(),通常是遇到了再写,受公司的启发,我自己简单写了个类来自动生成这些js,目的就是为了方便,一个小玩意,新手们也许会喜欢^_^
[php]
/*
*页面:makeJs.class.php
*功能:封装常用的JS代码,直接调用,方便操作
*作者:辉老大
*创建时间:2007-01-27
*/
class makeJs
{
private $jsStartChar = '
private $jsEndChar = '
/*
*函数名称:jsAlert
*函数功能:弹出JS提示框
*参数:$message 要在弹出提示框中显示的文字 $url 点击后跳转的路径,为空则不跳转
*使用方法:
*$js = new makeJs();//以下介绍使用方法省略此句
*$js->jsAlert(显示的文字,'跳转页面URL');//弹出对话框,点击确定后跳转到php.php页面
*$js->jsAlert(显示的文字,'');//弹出对话框,点击确定后没有跳转
*/
public function jsAlert($message,$url){
echo $this->jsStartChar;
if($url==''){
echo 'alert' . '("' . $message . '");';
echo $this->jsEndChar;
}
else{
echo 'alert' . '("' . $message . '");';
echo $this->jsEndChar;
echo '';
}
}
/*
*函数名称:jsConfirm
*函数功能:弹出JS提示框,带确定/取消
*参数:$message 要在弹出提示框中显示的文字
*使用方法:$js->jsConfirm('显示的文字');
*/
public function jsConfirm($message){
echo $this->jsStartChar;
if($url==''){
echo 'confirm' . '("' . $message . '");';
echo $this->jsEndChar;
}
}
/*
*函数名称:jsOpenWin
*函数功能:弹出新窗口
*参数:$url 路径 $name 窗口名 $height 窗口高度 $width 窗口宽度
*使用方法:
*$url = '页面的URL';
*$js->jsOpenWin($url,窗口名,窗口高度,窗口宽度);
*/
public function jsOpenWin($url,$name,$height,$width){
echo $this->jsStartChar;
echo 'window.open'.'("'.$url.'","'.$name.'","'.$height.'","'.$width.'");';
echo $this->jsEndChar;
}
/*
*函数名称:jsAddscrīpt
*函数功能:自定义JS
*参数:$scrīpt
*使用方法:
*$scrīpt = '定义的js语句';
*例如:$scrīpt = 'window.location=(\'php.php\')';
*$js->jsAddscrīpt($scrīpt);
*/
public function jsAddscrīpt($scrīpt){
echo $this->jsStartChar;
echo $scrīpt;
echo $this->jsEndChar;
}
}
?>
[/php]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

In-depth analysis of the top 15 Bitcoin Escape Index: Market Outlook for 2025 This article deeply analyzes fifteen commonly used Bitcoin Escape Index, among which the Bitcoin Rhodl ratio, USDT current wealth management and altcoin seasonal index have reached the Escape Index in 2024, attracting market attention. How should investors deal with potential risks? Let us interpret these indicators one by one and explore reasonable response strategies. 1. Detailed explanation of key indicators AHR999 coin hoarding indicator: Created by ahr999, assisting Bitcoin fixed investment strategy. The current value is 1.21, which is in the wait-and-see range, so it is recommended to be cautious. Link to AHR999 Escape Top Indicator: A supplement to AHR999 Coin Hoarding Indicator, used to identify the top of the market. The current value is 2.48, this week
