炫浪网首页 | 加入收藏夹 登录 | 注册
logo
网站导航: 炫浪首页游戏频道女性风采科技学院精品素材桌面壁纸BT影视网络社区健康生活
热门栏目: 炫友贴图编程开发硬件学堂博客空间游戏攻略游戏资源时尚女性美容护肤教程下载
炫浪(科技.学院)
 | 网站首页 | 系统软件 | 图形图像 | 编程开发 | 网络应用 | 硬件学堂 | 办公应用 | 〖图书馆〗 | 
  您现在的位置: 炫浪学院 >> 编程开发 >> 网页制作 >> Javascript >> 正文

菜鸟学习javascript实例教程

炫浪 科技.学院 时间:2007-8-20 13:24:35 来源:炫浪学院 发表评论 社区讨论

用JS显示文字的例子:

<html>
<body>

<script type="text/javascript">
document.write("Hello World!")
</script>

</body>
</html>

用HTML标签来格式化文本的例子:

<html>
<body>

<script type="text/javascript">
document.write("<h1>Hello World!</h1>")
</script>

</body>
</html>

书写JS位置的例子:

打开页面弹出窗口的例子

<html>
<head>
<script type="text/javascript">
function message()
{
alert("网页教学网欢迎你的光临")
}
</script>
</head>

<body onload="message()">

</body>
</html>


在BODY区内输出显示文本的例子:

<html>
<head>
</head>

<body>

<script type="text/javascript">
document.write("欢迎光临网页教学网http://www.webjx.com")
</script>

</body>
</html>


调用其它的一个JS文件的例子:

<html>
<head>
</head>
<body>

<script src="xxx.js">
</script>

<p>
The actual script is in an external script file called "xxx.js".
</p>

</body>
</html>


变量的使用


变量使用的例子:


<html>
<body>

<script type="text/javascript">
var name = "Hege"
document.write(name)
document.write("<h1>"+name+"</h1>")
</script>

<p>This example declares a variable, assigns a value to it, and then displays the variable.</p>

<p>Then the variable is displayed one more time, only this time as a heading.</p>

</body>
</html>


函数的例子

函数使用的一个例子:

<html>
<head>

<script type="text/javascript">
function myfunction()
{
alert("HELLO")
}
</script>

</head>
<body>

<form>
<input type="button"
onclick="myfunction()"
value="Call function">
</form>

<p>By pressing the button, a function will be called. The function will alert a message.</p>

</body>
</html>

带一个参数的函数的例子:

<html>
<head>

<script type="text/javascript">
function myfunction(txt)
{
alert(txt)
}
</script>

</head>
<body>

<form>
<input type="button"
onclick="myfunction('Hello')"
value="Call function">
</form>

<p>By pressing the button, a function with an argument will be called. The function will alert
this argument.</p>

</body>
</html>

不同的两个参数调用函数的例子:

<html>
<head>
<script type="text/javascript">

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

  • 上一篇文章:

  • 下一篇文章:
  • 发 表 评 论
    姓 名: 主 页:
    评 分: 1分 2分 3分 4分 5分
    内 容:
    频 道 推 荐

    优秀程序员的两大要

    信息时代如何成为一

    如何成为一名C++程序

    Java程序员认证模拟

    高级程序员级考试大

    初级程序员级考试大
    最 新 热 门
    相 关 文 章
    详细解析网页漂浮广告代码的含义
    整理:常用的网页特殊效果JS代码
    限制文本字节数的JS源代码程序
    JS来实现浏览器菜单的命令
    JS实现鼠标点击复制标题和地址
    javascript的使用技巧大全
    可以参考的一些javascript技术
    区分javascript,Js,VBScript,A
    让你的ewbeditor也能运行代码
    可以收缩和和伸展的表格
    相 关 新 贴
    广 告 展 示

    炫浪网 业务、广告:web#xvna.com (请将#换成@) 业务广告QQ 业务广告QQ2
    Copyright @ 2006-2007 All Right Reserved (主域名 xvna.com 粤ICP备07040110号)
    【声明】本网站部分内容属社区网友发布,本网站仅提供网友交流平台,但有权在本网站范围内引用、发布、转载来自论坛网友发布的内容。网友发布内容纯属个人行为,与本网站立场无关。本网站对于论坛网友发布的内容所引发的版权、署名权的异议及纠纷,不承担任何责任。其他媒体转载须事先与原作者和本网站联系。