javascript中輸出資訊的方法-資訊確認框-提示輸入框-文檔流輸出,javascript輸入框

來源:互聯網
上載者:User

javascript中輸出資訊的方法-資訊確認框-提示輸入框-文檔流輸出,javascript輸入框
js中輸出資訊的方法


1、文檔流輸出
document.write('hello');


2、輸出資訊氣球 模態對話方塊
   window.alert('要輸出顯示的內容');  或 alert('要輸出顯示的內容');
   alert(n);


3、資訊確認框
var f =  window.confirm('是否要進入新浪網');  confirm("");
if(f){
   location.href = 'http://www.sina.com.cn';    
}


4、提示輸入框
   window.prompt
   var n = window.prompt('請輸入年齡',18);
if(n>=18){
document.write('歡迎你年輕人');    
}


5、控制標籤,在標籤上直接輸出,
   通過document.getElementById('id') 找到對象標籤,可以直接控制裡邊的值,進行輸出
setInterval(function(){document.getElementById('ttt').innerHTML = "目前時間:"+new Date().toLocaleString();},1000);


<script>
document.getElementById('uname').value = "佚名";
</script>




6、把資訊直接輸出到標題
    document.title = "hello";
javascript訊息提示框代碼我突然忘記了代碼大概是這樣的:javascript('這個是提示框內容')

<script type="text/javascript">
alert("這個是提示框內容")

</script>
 
大家幫我看看這段javascript代碼為何讀取不到輸入框的內容?

document.getElementsByName方法,看名字就知道:Elements是複數,得到的是個數組!
單個標記的訪問最好用getElementByID
一般,name用在伺服器指令碼上,ID多用在客戶指令碼
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.