關于本篇的一些個人理解
②為何<script></script>放在頭部,輸出為 null?
var mychar = document.getElementById('con');
document.write(mychar);
<p id="con">javascript</p>
因為js執行順序由上至下,從上層開始優先執行,那這里因為<p>內容</p>放在了js腳本后面,所以先執行了js,才遇到的p。那么js是無法獲取到元素的,所以為null。
②為何<script></script>放在頭部,輸出為 null?
var mychar = document.getElementById('con');
document.write(mychar);
<p id="con">javascript</p>
因為js執行順序由上至下,從上層開始優先執行,那這里因為<p>內容</p>放在了js腳本后面,所以先執行了js,才遇到的p。那么js是無法獲取到元素的,所以為null。
2020-03-15
關于本篇的一些個人理解
①為何輸出結果是object HTMLParagraphElement?
<p id="con">javascript</p>
var mychar = document.getElementById('con');
document.write(mychar);
輸出object HTMLParagraphElement,因為它獲取的只是名字ID為con的元素,所以輸出結果等于“id為con的元素是p元素”
①為何輸出結果是object HTMLParagraphElement?
<p id="con">javascript</p>
var mychar = document.getElementById('con');
document.write(mychar);
輸出object HTMLParagraphElement,因為它獲取的只是名字ID為con的元素,所以輸出結果等于“id為con的元素是p元素”
2020-03-15
function openWindow()
{ var mymessage= confirm("打開默認URL");
if(mymessage==true)
{ // 打開默認URL
window.open('http://www.xianlaiwan.cn/')
}else{ //打開輸入的URL
var score = prompt("請輸入你要打開的URL:");
if(score != null){
window.open(score)}
else{window.colse} } }
{ var mymessage= confirm("打開默認URL");
if(mymessage==true)
{ // 打開默認URL
window.open('http://www.xianlaiwan.cn/')
}else{ //打開輸入的URL
var score = prompt("請輸入你要打開的URL:");
if(score != null){
window.open(score)}
else{window.colse} } }
function openWindow()
{
var conf=confirm('是否打開網站');
if(conf==true)
{
var web=prompt('請輸入網址','http://www.xianlaiwan.cn/');
window.open(web,'_blank','width=400,height=500,menubar=no,toolbar=no,status=no');
}
else{}
}
這是我的答案
{
var conf=confirm('是否打開網站');
if(conf==true)
{
var web=prompt('請輸入網址','http://www.xianlaiwan.cn/');
window.open(web,'_blank','width=400,height=500,menubar=no,toolbar=no,status=no');
}
else{}
}
這是我的答案
function openWindow(){
var con=confirm("是否打開新窗口?");
if(con==true){
var url=prompt("您要打開的網站是:","http://www.xianlaiwan.cn/");
if(url!=null){
window.open(url,'_blank','width=400px,height=500px,menubar=no,toolbar=no');
}
}
}
var con=confirm("是否打開新窗口?");
if(con==true){
var url=prompt("您要打開的網站是:","http://www.xianlaiwan.cn/");
if(url!=null){
window.open(url,'_blank','width=400px,height=500px,menubar=no,toolbar=no');
}
}
}
<script type = "text/JavaScript"> alert("JsDAIMA"); </script>
2020-02-15
這個任務絕對性的有毒??!明明說的是變量mychar內容,真實的結果不是變量的內容。而是內容maychar,也就是alert("mychar");,可以看出是腳本出錯了,判斷內容不是變量了!
2020-02-12