初学javascript--第一天

在javaSript的注释中的语句只有在支持javaScript的浏览器上才能显现

不支持的浏览器要使用

一旦使用则语句块不能再被使用.调用的是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”);以上的各个函数也可以集合使用

my string就是以上语句的功效

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”);
}

onClick//点击显示警告

javascript点击显示警告
这两句必须都放在之外

这了调用的一般不是有参数的函数.

for(var i=0;i<4;i++)循环可以这样些也可以这样

for(i=0;i<4;i++)
也就是说变量可以不声明就使用

很奇怪



这里竟然先调用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);用于取消时间调度

退出本页面是调用函数

var haveJava = navigator.javaEnabled();浏览器可用java则返回true

document.write(“

Dynamic
Content

“);当传入write的参数含有html标签时,输出时可以自动转换格式
这句话就显示加粗后的字样

  • 本文作者: 帐前卒
  • 本文链接: http://chillyc.info/2006/968606/
  • 版权声明: 本博客所有文章除特别声明外,只能复制超链接地址,且必须注明出处!