實用代碼(Javascript指令碼)

來源:互聯網
上載者:User
新視窗永遠置中

<script language="javascript">
<!--
function openwindow( url, winName, width, height)
{
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=1,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //僅適用於Netscape
+ "screeny=" + yposition + "," //僅適用於Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE
window.open( url,winName,theproperty );
}
//-->
</script>
<a href="javascript:openwindow('tan2.htm','anyname',300,300)">
開啟視窗</a>

文字框只有下線的CSS

<input name="reviewone" size="15" style="color: rgb(255,0,0); border-left: medium

none; border-right: medium none; border-top: medium none; border-bottom: 1px solid

rgb(192,192,192)">

全選全不選

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}
// End -->
</script>
<form name=myform action="" method=post>
<table>
<tr><td>
<b>請選擇下面的選項</b><br>
<input type=checkbox name=list value="1">Java<br>
<input type=checkbox name=list value="2">JavaScript<br>
<input type=checkbox name=list value="3">ASP<br>
<input type=checkbox name=list value="4">HTML<br>
<input type=checkbox name=list value="5">SQL<br>
<br>
<input type=button value="Check All" onClick="this.value=check(this.form.list)">
</td></tr>
</table>
</form>

按"全選"按鈕就可以全選文字框內文字

<form>
<input type=button value="全選"

onClick="javascript:this.form.txt.focus();this.form.txt.select();"><br>
<textarea NAME="txt" ROWS=10 COLS=35 WRAP=VIRTUAL>
按一下"全選"按鈕就可以選中這些字</textarea>
</form>

檢測選擇複選框個數

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function anyCheck(form) {
var total = 0;
var max = form.ckbox.length;
for (var idx = 0; idx < max; idx++) {
if (eval("document.playlist.ckbox[" + idx + "].checked") == true) {
total += 1;
}
}
alert("你選擇了 " + total + " 個選項.");
}
// End -->
</script>
<form method="post" name=playlist>
1<input type=checkbox name=ckbox>
2<input type=checkbox name=ckbox>
3<input type=checkbox name=ckbox>
4<input type=checkbox name=ckbox>
5<input type=checkbox name=ckbox>
6<input type=checkbox name=ckbox>
7<input type=checkbox name=ckbox>
8<input type=checkbox name=ckbox>
9<input type=checkbox name=ckbox>
<p><center><input type=button value="檢測選擇個數" onClick="anyCheck(this.form)">
</center></form>

滑鼠完全的被封鎖

<body oncontextmenu="return false" ondragstart="return false" onselectstart="return

false">

新視窗重新整理父視窗的幾種方式

父窗連結:
<a href="javascript:void" onClick="window.open('window.htm','','...')">開新窗</a>

新視窗:
1、點按鈕或文字
<a href="javascript:opener.location.reload()">重新整理</a>

2、開窗時重新整理
<body onload="opener.location.reload()">

3、關閉時重新整理
<body onUnload="opener.location.reload()">

相關文章

聯繫我們

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