初学javascript--第一天

在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标签时,输出时可以自动转换格式
这句话就显示加粗后的字样

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值