常用的JavaScript代碼(二),javascript代碼

來源:互聯網
上載者:User

常用的JavaScript代碼(二),javascript代碼
文章來自“PHP100中文網”


獲得時間所代表的微秒
var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()
視窗是否關閉
win.closed
checkbox扁平
<input type=checkbox style="position: absolute; clip:rect(5px 15px 15px 5px)"><br>
擷取選中內容
document.selection.createRange().duplicate().text
自動完成功能
<input type=text autocomplete=on>開啟該功能
<input type=text autocomplete=off>關閉該功能
視窗最大化
<body onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)">
無關閉按鈕IE
window.open("aa.htm", "meizz", "fullscreen=7");
統一編碼/解碼
alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe")))
encodeURIComponent對":"、"/"、";" 和 "?"也編碼
表格行指示
<tr onmouseover="this.bgColor='#f0f0f0'" onmouseout="this.bgColor='#ffffff'">

1.文字框焦點問題
onBlur:當失去輸入焦點後產生該事件
onFocus:當輸入獲得焦點後,產生該檔案
Onchange:當文字值改變時,產生該事件
Onselect:當文字加亮後,產生該檔案

<input type="text" value="郭強" onfocus="if(value=='郭強') {value=''}" onblur="if
(value=='') {value='郭強'}">點擊時文字消失,失去焦點時文字再出現


2.網頁按鈕的特殊顏色
<input type=button name="Submit1" value="郭強" size=10 class=s02

style="background-color:rgb(235,207,22)">

3.滑鼠移入移出時顏色變化
<input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue"

onMouseOver=this.style.color="red" class="button">

4.平面按鈕
<input type=submit value=訂閱 style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt;

BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">

5.按鈕顏色變化
<input type=text name="nick" style="border:1px solid #666666; font-size:9pt; height:17px;

BACKGROUND-COLOR: #F4F4FF; color:#ff6600" size="15" maxlength="16">

6.平面輸入框
<input type="text" name="T1" size="20" style="border-style: solid; border-width: 1">

7.使視窗變成指定的大小
<script>
window.resizeTo(300,283);
</script>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.