It does not work. When you click on a link, where do you want to execute a function? client-side or server-side? If you want to execute a function on the client side, then use javascript to do that. If you want to execute a function on the server side, you need to either change the url or do a form submission. Then you can execute the server-side function in that new page on the server-side.For example:<script language="javascript">
function clientFun()
{
alert("hello world");
}
</script>
<form action="whatever.php" method="post" name="frmtest">
<input type=hidden name="hello" value="world">
</form>
<a href="javascript:void(clientFun())">Client Side</a><BR>
<a href="javascript:void(location.href='another.php')">Change Link</a><br>
<a href="javascript:void(document.frmtest.submit())">Submit a form</a>
function clientFun()
{
alert("hello world");
}
</script>
<form action="whatever.php" method="post" name="frmtest">
<input type=hidden name="hello" value="world">
</form>
<a href="javascript:void(clientFun())">Client Side</a><BR>
<a href="javascript:void(location.href='another.php')">Change Link</a><br>
<a href="javascript:void(document.frmtest.submit())">Submit a form</a>
解决方案 »
- flexpaper不能显示由doc转化而来的swf
- php清空文本框
- PHPMYSQL编码问题?
- 求救!关于权限表读取的问题!
- 现在网络上有新PHP5虚拟空间吗?
- 请问可不可以通过程序结束一次Session?
- 类问题
- 有能耐的、有本事的、会写代码的、不是只会吹的……就来告诉我:如何获取<input type="file" name="upfile">中的内容,包括完整的路径和文
- 请教各位大侠:在Windows XP系统下安装PHPhome后系统提示PHP找不到指定的模块,能否解决?
- mysql的软件包里哪个是关闭主程序的啊 那个shutdown不管用啊
- 请问如何将一个数组里的所有元素初始化,以消除error_reporting函数的除错?
- 菜鸟级问题——请高手帮我看看这段代码错在哪里?只要对,分子马上送上!
<?php
funcion hello()
{ echo "hello world!<br>"; } if(isset($sbt)){
hello();
}else{
?>
<script language=Javascript1.1>
function form_submit(){
document.test.submit();
return;
}
</script>
<form name=test action="submit.php" method=post>
<input type=hidden name=sbt value="1">
<a href="Javascript:form_submit()">执行服务器端函数</a>
</form>
<?php
}
?>