加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php开发之javascript第一个程序

发布时间:2020-12-13 20:07:13 所属栏目:PHP教程 来源:网络整理
导读:关于基本的概念在这里就不说了,我依照书上的代码敲出了自己的第1个javasript程序,也就是自己的hello world 。对自己是1个很大的鼓励。下面我把代码贴出来和大家1块学习。 index.php ?php header( 'Content-type:text/html' ); include 'test.html' ; ? tes

关于基本的概念在这里就不说了,我依照书上的代码敲出了自己的第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>

运行结果以下:

这里写图片描述

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读