var isopen = confirm("是否打開");
if(isopen){
var urlInput;
urlInput=prompt("請輸入網址:","http://www.xianlaiwan.cn/");
if(urlInput){
window.open(urlInput,'_blank','width=400,height=500,top=100,left=0,menubar=yes,toolbar=yes, status=yes');
}
}
if(isopen){
var urlInput;
urlInput=prompt("請輸入網址:","http://www.xianlaiwan.cn/");
if(urlInput){
window.open(urlInput,'_blank','width=400,height=500,top=100,left=0,menubar=yes,toolbar=yes, status=yes');
}
}
可以用“document.write(mynum);”檢驗是否賦值成功:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>變量</title>
<script type="text/javascript">
var mynum;
mynum = 8;
document.write(mynum)
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>變量</title>
<script type="text/javascript">
var mynum;
mynum = 8;
document.write(mynum)
</script>
</head>
<body>
</body>
</html>
2016-06-21
function rec(){
var mymessage=confirm("你喜歡AV嗎") ;
if(mymessage!=true)
{
document.write("你是女士!");
}
else
{
document.write("你是男士!");
alert("你這個壞人,有毒");
}
var mymessage=confirm("你喜歡AV嗎") ;
if(mymessage!=true)
{
document.write("你是女士!");
}
else
{
document.write("你是男士!");
alert("你這個壞人,有毒");
}
2016-06-21
document.write("hello");
document.getElementById("p1").style.color="blue";
不要忘了區分大小寫和分號
document.getElementById("p1").style.color="blue";
不要忘了區分大小寫和分號
2016-06-21
<script type " text.javascript"><script>
2016-06-21
我記得獲得元素有三種形式:document.getElementById(); document.getElementByTagName(); document.getElementByName();后面兩種得到的是數組。
2016-06-21
如果在javascript前面加上window.onload = function(){}就是頁面加載完以后才會執行就不會顯示為null了
2016-06-21
function openWindow(){
var new1 = confirm("是否打開新的網頁");
if(new1==1){
window.open("http://www.xianlaiwan.cn","_black","width=400px","height=500px");
} else {
return;
}
}
var new1 = confirm("是否打開新的網頁");
if(new1==1){
window.open("http://www.xianlaiwan.cn","_black","width=400px","height=500px");
} else {
return;
}
}