国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > php教程 > php开发之javascript第一个程序

php开发之javascript第一个程序

来源:程序员人生   发布时间:2015-04-23 08:17:28 阅读次数:2698次

关于基本的概念在这里就不说了,我依照书上的代码敲出了自己的第1个javasript程序,也就是自己的hello world 。对自己是1个很大的鼓励。下面我把代码贴出来和大家1块学习。
index.php

<?php header('Content-type:text/html'); include 'test.html'; ?>

test.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <script type ="text/javascript"> function cubeme(incomingNum){ if(incomingNum ==1){ return "what are you doing ?"; }else{ return Math.pow(incomingNum,3); } } </script> <title>JavaScript Test</title> </head> <body> <script type ="text/javascript"> var theNum =2; var finalNum =cubeme(theNum); if(isNaN(finalNum)){ alert("You should know that 1 to any power is 1."); } else{ alert("when cubed ," + theNum + "is" + finalNum); } </script> </body> </html>

运行结果以下:

这里写图片描述

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生