初学javascript--第一天
2006-07-24 14:06
267 查看
在javaSript的注释中的语句只有在支持javaScript的浏览器上才能显现
不支持的浏览器要使用<noscript></noscript>
一旦使用<script language = "javaScript" src = "sa.js">语句块</script>则语句块不能再被使用.调用的是sa.js
这是两种定义字符串的方式
var value1 = '100';
var value2 = "kill you";
这是两种定义字符串的方式
var value5 = " world";
var value6 = (value5+value2).search("k");
var value7 = (value5+value2).replace("k",'c');
document.writeln(value6);这里得到6
document.writeln(value7);这里得到 worldcill you
big: Returns the string in big tags
blink: Returns the string in blink tags
bold: Returns the string in b tags
fixed: Returns the string in tt tags (for fixed-width display)
fontcolor: Returns the string in font tags with the color
attribute set to the color you specify as an argument
fontsize: Returns the string in font tags with the size attribute
set to the size you specify as an argument
italics: Returns the string in i tags
small: Returns the string in small tags
strike: Returns the string in strike tags (for a strikethrough
effect)
sub: Returns the string in sub tags (for a subscript effect)
sup: Returns the string in sup tags (for a superscript effect)
toLowerCase: Returns the string with all lowercase characters
toUpperCase: Returns the string with all upper case characters
variableName.big();
variableName.fontcolor(“red”);
variableName.toLowerCase();
document.writeln(value7.big());这样字体就变大了.
var finalString = firstString.bold().toLowerCase().fontcolor(“red”);以上的各个函数也可以集合使用
<font color=”red”><b>my string</b></font>就是以上语句的功效
for(var i=0;i<5;i++)
{
myArray1[i] = i;
document.writeln(myArray1[i]);
}
for(i=0;i<3;i++)//这样不会产生错误.和java不同.
{
document.writeln(myArray2[i]);
}
html和javascript都是在那里错才不显示.而并不是不能用浏览器浏览.
window.alert("hello");显示警告对话框
window.confirm("bye");显示确定对话框
function hello()
{
window.alert("hello");
}
<a href = "#" onClick = "hello();">onClick</a>//点击显示警告
<a href = "javascript:hello();">javascript</a>点击显示警告
这两句必须都放在<script></script>之外
<body onLoad = "warning();">这了调用的一般不是有参数的函数.
</body>
for(var i=0;i<4;i++)循环可以这样些也可以这样
for(i=0;i<4;i++)
也就是说变量可以不声明就使用
很奇怪
<head>
<script>
<!--
function warning()
{
window.alert("hello");
}
function firm()
{
return window.confirm("Open it?");
}
window.setTimeout("firm()",5000);
//-->
</script>
</head>
<body onLoad = "warning();">
<script>
var ok=firm();
...
</script>这里竟然先调用firm() 而后调用warning();
window.setTimeout("firm()",5000);5秒后自动跳出confirm对话框
function hello() {
window.alert(“Hello”);
window.setTimeout(“hello()”,5000);
}
这个每隔5秒的跳出confirm
var a = window.setTimeout("firm()",3000);
window.clearTimeout(a);用于取消时间调度
<body onUnload = "warning()">退出本页面是调用函数
var haveJava = navigator.javaEnabled();浏览器可用java则返回true
document.write("<p><strong>Dynamic Content</strong></p>");当传入write的参数含有html标签时,输出时可以自动转换格式
这句话就显示加粗后的字样
不支持的浏览器要使用<noscript></noscript>
一旦使用<script language = "javaScript" src = "sa.js">语句块</script>则语句块不能再被使用.调用的是sa.js
这是两种定义字符串的方式
var value1 = '100';
var value2 = "kill you";
这是两种定义字符串的方式
var value5 = " world";
var value6 = (value5+value2).search("k");
var value7 = (value5+value2).replace("k",'c');
document.writeln(value6);这里得到6
document.writeln(value7);这里得到 worldcill you
big: Returns the string in big tags
blink: Returns the string in blink tags
bold: Returns the string in b tags
fixed: Returns the string in tt tags (for fixed-width display)
fontcolor: Returns the string in font tags with the color
attribute set to the color you specify as an argument
fontsize: Returns the string in font tags with the size attribute
set to the size you specify as an argument
italics: Returns the string in i tags
small: Returns the string in small tags
strike: Returns the string in strike tags (for a strikethrough
effect)
sub: Returns the string in sub tags (for a subscript effect)
sup: Returns the string in sup tags (for a superscript effect)
toLowerCase: Returns the string with all lowercase characters
toUpperCase: Returns the string with all upper case characters
variableName.big();
variableName.fontcolor(“red”);
variableName.toLowerCase();
document.writeln(value7.big());这样字体就变大了.
var finalString = firstString.bold().toLowerCase().fontcolor(“red”);以上的各个函数也可以集合使用
<font color=”red”><b>my string</b></font>就是以上语句的功效
for(var i=0;i<5;i++)
{
myArray1[i] = i;
document.writeln(myArray1[i]);
}
for(i=0;i<3;i++)//这样不会产生错误.和java不同.
{
document.writeln(myArray2[i]);
}
html和javascript都是在那里错才不显示.而并不是不能用浏览器浏览.
window.alert("hello");显示警告对话框
window.confirm("bye");显示确定对话框
function hello()
{
window.alert("hello");
}
<a href = "#" onClick = "hello();">onClick</a>//点击显示警告
<a href = "javascript:hello();">javascript</a>点击显示警告
这两句必须都放在<script></script>之外
<body onLoad = "warning();">这了调用的一般不是有参数的函数.
</body>
for(var i=0;i<4;i++)循环可以这样些也可以这样
for(i=0;i<4;i++)
也就是说变量可以不声明就使用
很奇怪
<head>
<script>
<!--
function warning()
{
window.alert("hello");
}
function firm()
{
return window.confirm("Open it?");
}
window.setTimeout("firm()",5000);
//-->
</script>
</head>
<body onLoad = "warning();">
<script>
var ok=firm();
...
</script>这里竟然先调用firm() 而后调用warning();
window.setTimeout("firm()",5000);5秒后自动跳出confirm对话框
function hello() {
window.alert(“Hello”);
window.setTimeout(“hello()”,5000);
}
这个每隔5秒的跳出confirm
var a = window.setTimeout("firm()",3000);
window.clearTimeout(a);用于取消时间调度
<body onUnload = "warning()">退出本页面是调用函数
var haveJava = navigator.javaEnabled();浏览器可用java则返回true
document.write("<p><strong>Dynamic Content</strong></p>");当传入write的参数含有html标签时,输出时可以自动转换格式
这句话就显示加粗后的字样
相关文章推荐
- 2017.07.27am-初学Javascript的小笔记
- Javascript和python获取月份第一天和最后一天
- 初学JavaScript笔记,JavaScript对象
- JavaScript学习笔记第一天——运算符
- 老话重谈,給初学javascript的一点指引--谈JavaScript中面向对象技术的模拟
- JavaScript学习第一天
- Javascript 学习第一天
- 初学javascript的函数及闭包困惑
- javascript 初学教程及五子棋小程序的简单实现
- [导入]javascript 实现像excel样的自动求和功能。(初学的可以看看)
- 如何走出JavaScript初学困境
- JavaScript初学笔记(1)
- 初学链表第一天总结笔记
- 初学Struts2第一天,学习Struts基础配置,第一次写博文,写的不好勿喷哦
- 第一天 javascript
- JavaScript初学习javascript
- JavaScript学习心得之如何走出初学困境
- 利用Javascript获取当月第一天和当前日期(来自刚入行三个月菜鸟的第一篇Blog)
- 悟透JavaScript——第一天
- ASP无刷新技术之一(ASP+XMLHTTP+JavaScript)简析[适合初学入门者]