php输出javascript类
时间:2007-09-21 来源:jackliy
///
///
/// 输出 Javascript
///
///
/// 日出东方xp
///
///
/// 2004.6.27
///
///
/// 1.2
///
///
class Javascript
{
function Begin()
{
print "\n";
}
function End()
{
print "\n";
}
function Open($url, $target, $style)
{
print "open(\"" . $url . "\",\"" . $target . "\",\"" . $style . "\");\n";
}
function SetValue($name,$value,$form="")
{
print "\tSetValue(\"" . $name . "\",\"" . $value . "\"" . ($form==""?"": ",\"" . $form . "\"") . ");\n";
}
function GoToUrl($url,$wnd="")
{
print ($wnd!=""?$wnd.".":"")."window.location.href=\"" . $url . "\";\n";
}
function Alert($msg)
{
print "alert(\"" . $msg . "\");\n";
}
function GoBack()
{
print "history.back();\n";
}
function CloseWindow()
{
print "window.close();\n";
}
}
[/PHP]
SetValue 需要一些js函数的支持
[CODE]
function SetValue(name,value)
{
theForm="document.forms[0]";
if(arguments.length==3)
theForm = arguments[2];
theForm=eval(theForm);
//alert(name.type);
for(i=0;i
一个例子
[PHP]
$js = new Javascript();
$js->Begin();
$js->Alert("Hello world!");
$js->GoToUrl("http://www.hebca.com");
$js->End();
再发个例子。
php");
CheckUser("ADMIN");
if(@$_POST["name"])
{
$obj=new EasyDB(NOTICE);
$obj->Debug = true;
$obj->AcceptType = "USER";
$obj->User["name"] = $obj->Post["name"];
$obj->User["url"] = $obj->Post["url"];
$obj->User["status"] = $obj->Post["status"];
$obj->User["type"] = $obj->Post["type"];
$obj->User["width"] = $obj->Post["width"];
$obj->User["height"] = $obj->Post["height"];
$obj->User["pubuser"] = $_SESSION["UserId"];
$obj->User["pubusergroup"] = $_SESSION["UserGroup"];
if($obj->Insert())
{
$js = new Javascript();
$js->Begin();
$js->Alert("添加" . NOTICE_NAME . "成功!");
$js->GoToUrl($_SERVER["PHP_SELF"]);
$js->End();
}
else
{
Error("添加" . NOTICE_NAME . "失败!", $_SERVER["PHP_SELF"]);
}
exit();
}
?>
///
/// 输出 Javascript
///
///
/// 日出东方xp
///
///
/// 2004.6.27
///
///
/// 1.2
///
///
class Javascript
{
function Begin()
{
print "\n";
}
function End()
{
print "\n";
}
function Open($url, $target, $style)
{
print "open(\"" . $url . "\",\"" . $target . "\",\"" . $style . "\");\n";
}
function SetValue($name,$value,$form="")
{
print "\tSetValue(\"" . $name . "\",\"" . $value . "\"" . ($form==""?"": ",\"" . $form . "\"") . ");\n";
}
function GoToUrl($url,$wnd="")
{
print ($wnd!=""?$wnd.".":"")."window.location.href=\"" . $url . "\";\n";
}
function Alert($msg)
{
print "alert(\"" . $msg . "\");\n";
}
function GoBack()
{
print "history.back();\n";
}
function CloseWindow()
{
print "window.close();\n";
}
}
[/PHP]
SetValue 需要一些js函数的支持
[CODE]
function SetValue(name,value)
{
theForm="document.forms[0]";
if(arguments.length==3)
theForm = arguments[2];
theForm=eval(theForm);
//alert(name.type);
for(i=0;i
一个例子
[PHP]
$js = new Javascript();
$js->Begin();
$js->Alert("Hello world!");
$js->GoToUrl("http://www.hebca.com");
$js->End();
再发个例子。
php");
CheckUser("ADMIN");
if(@$_POST["name"])
{
$obj=new EasyDB(NOTICE);
$obj->Debug = true;
$obj->AcceptType = "USER";
$obj->User["name"] = $obj->Post["name"];
$obj->User["url"] = $obj->Post["url"];
$obj->User["status"] = $obj->Post["status"];
$obj->User["type"] = $obj->Post["type"];
$obj->User["width"] = $obj->Post["width"];
$obj->User["height"] = $obj->Post["height"];
$obj->User["pubuser"] = $_SESSION["UserId"];
$obj->User["pubusergroup"] = $_SESSION["UserGroup"];
if($obj->Insert())
{
$js = new Javascript();
$js->Begin();
$js->Alert("添加" . NOTICE_NAME . "成功!");
$js->GoToUrl($_SERVER["PHP_SELF"]);
$js->End();
}
else
{
Error("添加" . NOTICE_NAME . "失败!", $_SERVER["PHP_SELF"]);
}
exit();
}
?>
相关阅读 更多 +
排行榜 更多 +