- 浏览: 362292 次
- 性别:
最新评论
-
天使建站:
这里这篇文章更详细 还有完整的实例演示:js跳出循环:brea ...
js跳出循环的方法区别(break,continue,return) -
jahentao:
我觉得Jcreator和eclipse中的列出属性和方法,很多 ...
反射原理 -
T240178168:
相互交流下吧
ie9以下都有这个问题(ajax) -
blackproof:
试了一下,的确第一种写法oracle优化了,效率比第二种快多了 ...
Oracle分页sql语句 -
杨白白:
进程与线程
1)Alert box
<html>
<head>
<script type="text/javascript">
function disp_alert()
{
alert("I am an alert box!!")
}
</script>
</head>
<body>
<input type="button" onclick="disp_alert()" value="Display alert box" />
</body>
</html>
(2) confirm box
<html>
<head>
<script type="text/javascript">
function disp_confirm()
{
var r=confirm("Press a button")
if (r==true)
{
document.write("You pressed OK!")
}
else
{
document.write("You pressed Cancel!")
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_confirm()" value="Display a confirm box" />
</body>
</html>
(3)
Prompt box
<html>
<head>
<script type="text/javascript">
function disp_prompt()
{
var name=prompt("Please enter your name","Harry Potter")
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?")
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_prompt()" value="Display a prompt box" />
</body>
</html>
(4)
Call a function1
<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>
(5)
Function with an argument
<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>
(7)Function with an argument 2
<html>
<head>
<script type="text/javascript">
function myfunction(txt)
{
alert(txt)
}
</script>
</head>
<body>
<form>
<input type="button"
onclick="myfunction('Good Morning!')"
value="In the Morning">
<input type="button"
onclick="myfunction('Good Evening!')"
value="In the Evening">
</form>
<p>
When you click on one of the buttons, a function will be called. The function will alert
the argument that is passed to it.
</p>
</body>
</html>
(8)
Function_return
<html>
<head>
<script type="text/javascript">
function myFunction()
{
return ("Hello, have a nice day!")
}
</script>
</head>
<body>
<script type="text/javascript">
document.write(myFunction())
</script>
<p>The script in the body section calls a function.</p>
<p>The function returns a text.</p>
</body>
</html>
(9)
<html>
<head>
<script type="text/javascript">
function product(a,b)
{
return a*b
}
</script>
</head>
<body>
<script type="text/javascript">
document.write(product(4,3))
</script>
<p>The script in the body section calls a function with two parameters (4 and 3).</p>
<p>The function will return the product of these two parameters.</p>
</body>
</html>
(10)
for
<html>
<body>
<script type="text/javascript">
for (i = 0; i <= 5; i++)
{
document.write("The number is " + i)
document.write("<br />")
}
</script>
<p>Explanation:</p>
<p>This for loop starts with i=0.</p>
<p>As long as <b>i</b> is less than, or equal to 5, the loop will continue to run.</p>
<p><b>i</b> will increase by 1 each time the loop runs.</p>
</body>
</html>
(11)
<html>
<body>
<script type="text/javascript">
for (i = 1; i <= 6; i++)
{
document.write("<h" + i + ">This is header " + i)
document.write("</h" + i + ">")
}
</script>
</body>
</html>
(12)
while
<html>
<body>
<script type="text/javascript">
i = 0
while (i <= 5)
{
document.write("The number is " + i)
document.write("<br />")
i++
}
</script>
<p>Explanation:</p>
<p><b>i</b> is equal to 0.</p>
<p>While <b>i</b> is less than , or equal to, 5, the loop will continue to run.</p>
<p><b>i</b> will increase by 1 each time the loop runs.</p>
</body>
</html>
(13)
do...while
<html>
<body>
<script type="text/javascript">
i = 0
do
{
document.write("The number is " + i)
document.write("<br />")
i++
}
while (i <= 5)
</script>
<p>Explanation:</p>
<p><b>i</b> equal to 0.</p>
<p>The loop will run</p>
<p><b>i</b> will increase by 1 each time the loop runs.</p>
<p>While <b>i</b> is less than , or equal to, 5, the loop will continue to run.</p>
</body>
</html>
(14)
break
<html>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
if (i==3){break}
document.write("The number is " + i)
document.write("<br />")
}
</script>
<p>Explanation: The loop will break when i=3.</p>
</body>
</html>
(15)
try...catch
<html>
<head>
<script type="text/javascript">
var txt=""
function message()
{
try
{
adddlert("Welcome guest!")
}
catch(err)
{
txt="There was an error on this page.\n\n"
txt+="Error description: " + err.description + "\n\n"
txt+="Click OK to continue.\n\n"
alert(txt)
}
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>
- Javascript基础教程_文字版_代码可复制_.pdf (587.4 KB)
- 描述: 基础
- 下载次数: 8
发表评论
-
ie9以下都有这个问题(ajax)
2016-01-18 17:01 1336ajax在IE下使用GET方式请求,如果地址和参数一样 会首先 ... -
Jquery绑定事件(bind和live的区别)
2015-04-27 21:56 1195Jquery中绑定事件有三种方法:以click事件为例 ... -
js字符串转换成数字
2015-01-14 23:33 4152js字符串转换成数字 js ... -
table中div内容为纯数字和字母换行
2014-12-29 20:01 1271不换行 简单些td中加white-space: nowrap; ... -
java 方式的将 java 对象以及 list 或者 map 转化为 json 数据
2014-03-12 23:40 1204JavajsonAjax.net 学会了在 j2ee中使用 ... -
query each方法跳出循环,并获得返回值
2014-03-12 23:26 1131return false:将停止循环 (就像在普通的循环中使用 ... -
js跳出循环的方法区别(break,continue,return)
2014-03-12 23:24 20650跟许多多态语言一样,js也有break,continue,re ... -
jsp中的乱码怎么解决
2014-03-06 21:41 8501、在jsp页中加入一条语句: <%@ page co ... -
image 不提交表单
2014-03-06 21:24 726默认input的type为image或者submit都会提交的 ... -
HTML表格中的nowrap是什么意思啊?
2013-11-03 22:34 2383HTML <td> 标签的 nowrap 属性 ... -
IFrame AND window对象
2013-07-20 01:07 1858var detialIframe=document.all(& ... -
window.onload
2013-07-20 01:02 1582window.onload 同时执行多个函数的解决方法 1. ... -
关键词高亮显示
2012-10-27 23:18 1117<!DOCTYPE html PUBLIC " ... -
前台javascript速度优化
2012-10-20 18:26 2653两个基本点 1. 择重避轻,有所取舍。 l ... -
简单javascript概述
2012-10-20 18:19 2456什么是JavaScript JavaScript ... -
禁止网页复制的代码
2012-09-11 22:59 2264<html> <head> < ... -
JS打印
2012-09-11 22:56 2449一、普通打印(整页打) 这个不用多说,直接用 引用:wi ... -
JS优化经验
2012-08-16 22:00 22701.定义局部变量。对于 ... -
js优化(收集一)
2012-08-16 21:58 37121.使用局部变量避免使用全局变量 比如 fun ... -
Javascript继承
2012-08-15 22:40 2260(一)对象冒充 JScript code funct ...
相关推荐
本篇文章主要是对C#执行Javascript代码的几种方法进行了详细的总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助
前端代码规范总结(3篇),包括HTML、CSS、JAVASCRIPT等代码规范的总结心得!
本篇文章给大家分享了关于javascript代码优化的8点总结,希望我们整理的内容能够帮助到大家。
都是支持到IE8及已上版本即可,那么这篇文章,粗浅的总结一下,如何判断浏览器是IE及版本是8.0 首先,有些属性和方法是所有版本IE都不支持,那么只需要判断是否是IE即可 以下三种是我在项目中,用到的方法,如有...
也许你很难从网上找到一篇从代码层面讲解内网穿透的文章,我曾搜过,未果,遂成此文。 1. 局域网内代理 我们先来回顾上篇,如何实现一个局域网内的服务代理?因为这个非常简单,所以,直接上代码。 const ...
下面是我总结的一些小技巧,仅供参考。 以下代码基本上在jQuery的源码里面都可以看到,如有说得不对的地方,请大家指出。 尽量使用源生方法 javaScript是解释性语言,相比编译性语言执行速度要慢。浏览器已经实现的...
很早就接触过闭包这个概念了,但是一直糊里糊涂的,没有能够弄明白JavaScript的闭包到底是什么,有什么用,今天在网上看到了一篇讲JavaScript闭包的文章(原文链接),讲得非常好,这下算是彻底明白了JavaScript的闭包...
一篇文章弄懂js中的typeof用法 目录 基础 返回类型 string 和 boolean number 和 bigint symbol undefined function object 其他 常见问题 引用错误 typeof null typeof 的局限性 扩展:BigInt 类型 总结 基础 ...
深入理解JavaScript系列,超实用的jQuery代码段,jQuery源码分析系列。
下面小编就为大家带来一篇JavaScript代码性能优化总结(推荐)。小编觉得挺不错的,现在分享给大家,也给大家做个参考,一起跟随小编过来看看吧,祝大家游戏愉快哦
下面对使用JavaScript实现页面定时跳转(也称倒计时跳转)做一下总结,各种定时跳转代码记录如下: (1)使用 setTimeout 函数实现定时跳转(如下代码要写在body区域内) 代码如下: [removed] // 3秒钟之后跳转到...
本来在那片编写可维护性代码文章后就要总结这篇代码性能文章的,耽搁了几天,本来也是决定每天都要更新一篇文章的,因为以前欠下太多东西没总结,学过的东西没去总结真的很快就忘记了,记录一下在你脑力留下更深的...
编程是一件很快乐的事,实现一个目的,我们可以有很多方法路径,在这篇文章我们介绍一些JavaScript的奇技淫巧,仅供大家参考,各路大神在平时的代码编写时,如很多简洁高效的书写方式; 下面话不多说了,来一起看看...
之前记录过JavaScript中判断为数字类型的多种方式,这篇看看如何判断为整数类型(Integer)。 JavaScript中不区分整数和浮点数,所有数字内部都采用64位浮点格式表示,和Java的double类型一样。但实际操作中比如数组...
如果您希望一遍又一遍地运行相同的代码,并且每次的值都不同,那么使用循环是很方便的,javascript中for循环也是非常常用的,下面这篇文章主要介绍了Javascript中for循环的几种写法,需要的朋友可以参考借鉴,一起来看...
这几天除了上课之外有空我都是在啃着它的源码,在网上相关资料基本一点都没找到,发觉看起来真是很吃力,这篇总结也只是说个大概原理,具体细节我也很多不明白,虽然很多代码都读得懂,但是串联起来有很大问
前言:javascript里变量作用域是个经常让人头痛抓狂的问题,下面通过10++个题目,对经常遇到又容易出错的情况进行了简单总结,代码样例很短很简单 题目一 代码如下: var name = ‘casper’; alert(name); /...
在上篇文章给大家介绍了JavaScript实现跑马灯抽奖活动实例代码解析与优化(一),既然是要编写插件。那么叫做“插件”的东西肯定是具有的某些特征能够满足我们平时开发的需求或者是提高我们的开发效率。那么叫做插件...