|
復(fù)制代碼 代碼如下:
<?php
echo <<<JS //使用多行輸出的方法輸出JavaScript代碼
<SCRIPT Language = "JavaScript">
function func()
{
if(confirm("Are you OK with this?"))
{
document.write("I'm OK!");
}
else
{
document.write("I'm not OK!");
}
}
</SCRIPT>
JS;
?>
<html>
<head>
</head>
<body>
<a href="#" href="#" onClick="Javascript:func();">Please Click</a>
</body>
</html>
復(fù)制代碼 代碼如下:
<?php
$confirm = "Are you OK with this?"; //定義確認框上的信息
$ok_msg = "I'm OK!"; //OK時的信息
$not_ok_msg = "I'm not OK!"; //Cancel時的信息
echo "<SCRIPT Language = /"JavaScript/">"; //開始逐行輸出JavaScript代碼
echo "function func()";
echo "{";
echo "if(confirm(/"Are you OK with this?/"))";
echo "{";
echo "document.write(/"I'm OK!/");";
echo "}";
echo "else";
echo "{";
echo "document.write(/"I'm not OK!/");";
echo "}";
echo "}";
echo "</SCRIPT>"; //輸出結(jié)束
?>
<html>
<head>
</head>
<body>
<a href="#" href="#" onClick="Javascript:func();">Please Click</a>
</body>
</html>
php技術(shù):php動態(tài)生成JavaScript代碼,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。