`

常用JS Claass

阅读更多

<?php
/**
* JS class.
*
* BugFree is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* BugFree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BugFree; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.okooo.com/OpenSource/
* @copyright Copyright: 2004-2004 Beijing SeaSun Media and Technology Co. Ltd.
* @author designer: Zhenfei Liu <liuzf@pku.org.cn> <br />
* developer: Chunsheng Wang <wwccss@263.net> <br />
* @package BugFree
* @version $Id: JS.class.php,v 1.3 2004/11/30 10:42:21 wangcs Exp $
*/
class JS
{
/**
* show a alert box.
*
* @param string $Text the text to be showd in the alert box.
*/
var $Charset = "UTF-8";

function alert($Text)
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo '<Script language="Javascript">alert("'.$Text.'");</Script>';
echo "\n";
echo "\n</body></html>";
}

/**
* show a confirm box, press ok go to URL1, else go to URL2.
*
* @param string $Text the text to be showed.
* @param string $URL1 the url to go to when press 'ok'.
* @param string $URL2 the url to go to when press 'cancle'.
* @param string $Target the name of the window to change location.
*/
function confirm($InfoText,$URL1,$URL2,$Target="self")
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo '<script language="javascript">
if (confirm("'.$InfoText.'"))
{
if("'.$URL1.'" == "Back")
{
history.back(-1)
}
else
{
'.$Target.'.location = "'.$URL1.'"
}
}
else
{
if("'.$URL2.'" == "Back")
{
history.back(-1)
}
else
{
'.$Target.'.location = "'.$URL2.'"
}
}
</script>';
echo "\n</body></html>";
}

/**
* change the location of the $Target window to the $URL.
*
* @param string $URL
* @param string $Target
*/
function goto($URL,$Target="self")
{
if ($URL == "Back")
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo "<Script Language=\"Javascript\">history.go(-1)</Script>";
echo "\n</body></html>";
}
elseif ($URL == "Back2")
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo "<Script Language=\"Javascript\">history.go(-2)</Script>";
echo "\n</body></html>";
}
else
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo "<Script Language=\"Javascript\">".$Target.".location=\"".$URL."\"</Script>";
echo "\n</body></html>";
}
}

/**
* select an item of a select box.
*
* @param string $ObjName the object name of the select box.
* @param string $ItemValue the value of the item to be selected.
* @param string $FunctionName the name of the function to create. If empty, execute directly.
* @param booble $Echo show directly or false.
*/
function selectOption($ObjName,$ItemValue,$FunctionName="",$Echo=false)
{
$JS = " <script language='Javascript'>";
if(!empty($FunctionName))
{
$JS .= "function $FunctionName(){";
}
$JS .="
var Value='".$ItemValue."';
for(I = 0;I < ".$ObjName.".options.length; I++)
{
if(Value.indexOf(',') >=0)
{
ValueList = Value.split(',');
for(Y = 0;Y < ValueList.length;Y++)
{
if(ValueList[Y] == ".$ObjName.".options[I].value)
{
".$ObjName.".options[I].selected = true;
}
}
}
else if(Value == ".$ObjName.".options[I].value)
{
".$ObjName.".options[I].selected = true;
}
}";
if(!empty($FunctionName))
{
$JS .= "}";
}
$JS .="
</script>
";
if($Echo)
{
echo $JS;
}
return $JS;
}
/**
* select an item of a group of radios.
*
* @param string $ObjName the object name of the radios.
* @param string $ItemValue the value of the item to be selected.
* @param booble $Echo show or false.
*/
function selectRadio($ObjName,$ItemValue,$Echo=false)
{
$JS = '<script language="javascript">';
$JS .= '
for(I=0;I<'.$ObjName.'.length;I++)
{
if('.$ObjName.'[I].value == "'.$ItemValue.'")
{
'.$ObjName.'[I].checked=true;
}
}';
$JS .= "</script>\n";
return $JS;
}

/**
* close current window.
*
*/
function closeWindow()
{
echo "<HTML>\n<HEAD>\n<TITLE> New Document </TITLE>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$this -> Charset}\">\n</HEAD>\n<BODY>\n";
echo "<script language=javascript>window.close();</script>";
echo "\n</body></html>";
}
}
?>
<?php
/**
* $Log: JS.class.php,v $
* Revision 1.3 2004/11/30 10:42:21 wangcs
* * change the comments to english.
*
*/
?>

分享到:
评论

相关推荐

    常用的JS后台导航菜单,可刷新不变

    常用的JS后台导航菜单,可刷新不变 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xml:lang="UTF-8" lang="UTF-8"&gt; &...

    新手常用的几个JS封装类

    新手常用的几个JS封装类: 包括拖拽、class添加删除、变换、继承等

    javaScript一些常用功能

    javaScript一些常用功能代码 js属性代码 (10,1) type=button value=属性&gt; &lt;OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0&gt; 可能提示“权限不足”

    详解用JS添加和删除class类名

    在写tab切换的时候,通常我们会给选中的tab设置不同的样式,常用的方法是给被选中的tab新增一个class名,然后改这个class名的样式。 比如 起一个class名叫“active” 设置样式 .active{ color: #FFD113 !...

    javascript代码常用大全

    一、验证类 1、数字验证内 1.1 整数 1.2 大于0的整数 (用于传来的ID的验证) ...object classid=&gt;相关类,如播放器,flash与脚本互动等 16, 刷新/模拟无刷新 异步调用类(XMLHttp或iframe,frame)

    最常用的200个JS代码.rar

    站长常用的200个JS代码 Download from codepub.com 1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后...

    JQUERY选择器 id选择器<br> 2)  $('.class')  css选择器,class类名<br>

    2) $('.class') css选择器,class类名 3) $('element') 标签选择器,例如p,h1,div 4) $('*') 全选择器,可选择所有的html标签(影响范围较大甚用) 5) $('sele1,sele2') 用‘,'逗号隔开可以选择...

    javascript 常用代码大全

    一、验证类 1、数字验证内 1.1 整数 1.2 大于0的整数 (用于传来的id的验证) ...14,各种&lt;object classid=&gt;相关类,如播放器,flash与脚本互动等 16, 刷新/模拟无刷新 异步调用类(xmlhttp或iframe,frame)

    web开发常用js库(效果库、架构库)

    自己写的一个网页开发常用效果库与框架库,可以自定义导出自己想要的部分。...2.面向对象的class方法-方便定义类与集成类; 3.require-实现模块化开发,简单实用; 提示:用!!!!!!标注结尾的在某些场景下可能出现bug;

    JS类中定义原型方法的两种实现的区别

    我们知道,给JavaScript类添加原形(prototype)方法是很简单的。而且常用的有下面这两种方法,可是这两种方法在使用时有区别吗?  JScript Class:  function JSClass()  {  }  Extends prototype method:  ...

    用原生JS获取CLASS对象(很简单实用)

    听说是最常用。。。。我是看了dom编程艺术想到的。 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;...sty

    javascript常用代码大全.html

    包括: 一、验证类 1、数字验证内 1.1 整数 1.2 大于0的整数 (用于传来的ID的验证) ...14,各种&lt;object classid=&gt;相关类,如播放器,flash与脚本互动等 16, 刷新/模拟无刷新 异步调用类(XMLHttp或iframe,frame)

    js 实现国密sm2、sm3、sm4 加密解密demo

    常用的主要有SM2,SM3,SM4。 SM2:椭圆曲线公钥密码算法是我国自主设计的公钥密码算法,为非对称加密,基于ECC。该算法已公开。由于该算法基于ECC,故其签名速度与秘钥生成速度都快于RSA。 SM3:消息摘要。可以用MD...

    vue动态绑定class的几种常用方式小结

    主要介绍了vue动态绑定class的几种常用方式,结合实例形式总结分析了vue.js常见的对象方法、数组方法进行class动态绑定相关操作技巧,需要的朋友可以参考下

    php简单封装了一些常用JS操作

    在web编程中大家应该会经常用到一些常用js操作,例如 alert(),通常是遇到了再写,受公司的启发,我自己简单写了个类来自动生成这些js,目的就是为了方便,一个小玩意,新手们也许会喜欢^_^ [php] &lt;...

    前端纯js加密、以及后端java解密代码 js 实现国密sm2、sm3、sm4 加密解密demo

    常用的主要有SM2,SM3,SM4。 SM2:椭圆曲线公钥密码算法是我国自主设计的公钥密码算法,为非对称加密,基于ECC。该算法已公开。由于该算法基于ECC,故其签名速度与秘钥生成速度都快于RSA。 SM3:消息摘要。可以用MD...

    Eclipse常用插件

    JadClipse:Java反编译插件(使用时注意在Eclipse配置关联:*.class和*.class without source 关联 类反编译查看器) OpenExplorer:Eclipse中快速打开本地文件系统 PropertiesEditor:Properties文件编辑工具,...

    前端项目-min.js.zip

    前端项目-min.js,一个非常小的javascript库,用于执行简单的DOM查询和挂接事件侦听器。目的是使用诸如element.classlist或element.innerhtml等html5(et al)技术返回原始DOM节点,以便您直接操作。

    常用JavaScript代码提示公共类封装

    namespace Jake.PublicJS { /// &lt;summary&gt; /// Summary description for PublicJS /// &lt;/summary&gt; public class PublicJS { public PublicJS() { // // TODO: Add constructor logic here // } /// &lt;summary&gt; /// 1...

Global site tag (gtag.js) - Google Analytics