如何用Javascript判斷圖片大小,其實只要寫一個簡單的函數就可以了,當然這么判斷要怎么寫很多人可能不知道。發覺用 ASP 判斷圖片大小比數牛毛還繁復, 且判斷了就判斷了, 還要邏輯顯示。..煩。 用 Javascript 判斷, 輕松搞定, 最終效果無非就是不要讓大圖片撐破頁面。
<script LANGUAGE=“JAVASCRIPT”>//檢查圖片大小是否大于預期大小, 大于則顯示為預期大小function show(chkw) { //chk images widthif(chkw>500) {chkw=500;}else {chkw=chkw;}return chkw;}//shawl.qiu script//example <img src=“images/teach/opera/01.jpg” onload=“this.width=show(this.width)” ></script>1.鼠標經過自動選取的復選框:<input TYPE=“checkbox” onMouseMove=“checked=true”><input TYPE=“checkbox” onMouseMove=“checked=true”>2.ACCESS 列出某一天所屬星期的天數//這個算法可費了我個把小時查詢一個日期所隸屬星期所有天數的數據SELECT *FROM ctdate_by_query_dateWHERE dateandtime between ((#2006-5-15#+Weekday(2006-5-15))-6) and #2006-5-15#+Weekday(2006-5-15)3. 雙擊滑鼠拷貝文本, 現在雙擊一下就清楚<script LANGUAGE=“JAVASCRIPT”>function ClipBoard(tdObj) { //IE Onlyvar holdtext = document.all[‘holdtext'];holdtext.innerText = tdObj.innerText;Copied = holdtext.createTextRange();Copied.execCommand(“Copy”);alert(“text copied”);}</script><form NAME=“form1” METHOD=“post” ACTION=“”><ttextarea id=“holdtext” style=“display:none” ROWS=“10”></ttextarea></form>
新聞熱點
疑難解答