js
共 4 篇文章
js 問題
1. head... <script> alert(document.getElementById("xx")); </script> body.... <label id="xx">yy</label> 發現alert出來為空。網上找了下,原因是js在頁面載入完就開始執行,所以可以把js放到最後面。或者用onload。
2012-08-22 14:18 · js
JS实现Trim()
转至: http://www.cnblogs.com/qixuejia/archive/2010/08/11/1797523.html //js去除空格函数 //此处为string类添加三个成员 String.prototype.Trim = function(){ return Trim(this);} String.prototype.LTrim = function(){return LTrim(this);} String.prototype.RTrim = function(){return RTrim(this);} //此处为独立函数 function LTrim(str) {…
2012-08-03 16:07 · js
获取页面高宽
<script> function getInfo() { var s = ""; s += " 网页可见区域宽:"+ document.body.clientWidth; s += " 网页可见区域高:"+ document.body.clientHeight; s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"; s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)"; s += " 网页正文全文宽:"+ document.body.scrollWidth…
2012-06-26 17:42 · js
js小技巧
1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document) 5.得到表单中元素的名称和值:document.getElementById("表单中元素的ID号").name(或value) 6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("…
2012-03-11 09:20 · js · JS