document.getElementById(“id”) 這條語句獲取的是元素,包含開始標簽到結束標簽所有內容。想要輸出元素內容需要在其后尾使用.innerHTML /*innerHTML看它的英文單詞也可以明白就是里面的字符按html標記的語言格式取出來*/
2015-12-06
<script type="text/javascript">
var mp=window.open('http://www.xianlaiwan.cn');//將新打開的窗口對象,存儲在變量mp中
mywin.close();
</script>
var mp=window.open('http://www.xianlaiwan.cn');//將新打開的窗口對象,存儲在變量mp中
mywin.close();
</script>
2015-12-06
function Wopen(){
var wopen()=window.open('http://www.xianlaiwan.cn','_blank','width=300,height=200,mennubar=no,toolbar=no,status=no,scrollbars=yse');
wopen();
}
var wopen()=window.open('http://www.xianlaiwan.cn','_blank','width=300,height=200,mennubar=no,toolbar=no,status=no,scrollbars=yse');
wopen();
}
2015-12-06
var myname=prompt("請輸入你的姓名:");
if(myname!=null){
alert("你好,"+myname);
}else{
alert("你好,我的朋友");
}
</script>
</head>
<body>
<input name="button" type="button" onClick="myname()" value="點擊我,對成績做評價!" />
if(myname!=null){
alert("你好,"+myname);
}else{
alert("你好,我的朋友");
}
</script>
</head>
<body>
<input name="button" type="button" onClick="myname()" value="點擊我,對成績做評價!" />
2015-12-06
function r(){
var check=confirm("您是中國人嗎?");
if(check==true)
{
document.write("我是中國人");
}else{
document.write("我不是中國人");
}
}
</script>
</head>
<body>
<input name="button" type="button" onClick="r()" value="點擊我,彈出確認對話框" /> 很簡單
var check=confirm("您是中國人嗎?");
if(check==true)
{
document.write("我是中國人");
}else{
document.write("我不是中國人");
}
}
</script>
</head>
<body>
<input name="button" type="button" onClick="r()" value="點擊我,彈出確認對話框" /> 很簡單
2015-12-06
function openWindow(){
// 新窗口打開時彈出確認框,是否打開
var nowwind=prompt("是否打開新窗口","http://www.xianlaiwan.cn/")
// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
if(nowwind != null){
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
window.open(nowwind,'_bank','width=400,height=500');
}
}
// 新窗口打開時彈出確認框,是否打開
var nowwind=prompt("是否打開新窗口","http://www.xianlaiwan.cn/")
// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
if(nowwind != null){
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
window.open(nowwind,'_bank','width=400,height=500');
}
}
我們在訪問網站的時候,有時會突然彈出一個小窗口,上面寫著一段提示信息文字。如果你不點擊“確定”,就不能對網頁做任何操作,這個小窗口就是使用alert實現的。
2015-12-05
<script type="text/javascript">
var mychar= document.getElementById("con");
document.write("結果:"+mychar); //輸出獲取的P標簽。
</script>
var mychar= document.getElementById("con");
document.write("結果:"+mychar); //輸出獲取的P標簽。
</script>
2015-12-05