您的位置:首页 > Web前端 > JavaScript

第一阶段JavaScript的学习总结

2009-08-02 10:32 489 查看
学习了

1.通过document.getElementById("helloMessage").innerHTML="hello,world!";<h1 id="helloMessage"></h1>来把输出内嵌到<h1>标签里面。

2.alert()函数对用户的警告。

3.通过prompt("are you sure you want to do that:","default");函数来对用户进行提示具体:

var ans=prompt("are you sure you want to do that:","default"); ans既是一个Boolean值也是一个被赋值的变量。"default"为默认回复

if(ans){

alert("you said "+ans);

}

else{

alert("you refused to answer");

}

4.通过confirm(" ");来确认用户的选择。返回一个Boolean值。

5.用链接对用户进行重定向。具体看实例:

window.onload=initAll;//当页面装载完成时,就调用initAll函数;

function initAll(){

document.getElementById("redirect").onclick=initRedirect;

}

function initRedirect(){

alert("we are not responsible for the content of pages outside our site");

window.location="jswelcome.html";

return false;//表示停止对用户点击的处理,这样就不会装载href指向的页面;反之则又转到href指向的页面。

//window.location=this;也可以转到href指向的页面,直接return true也可以。

}

对应的HTML端<a href="j_3.html" id="redirect">click here to the other page</a>

6.通过一个bingo实例来熟悉了循环、函数的值传递、对象的探测、数组的处理。还学习了错误的处理。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: