首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>Javascript教程>资讯:常用JavaScript代码4

常用JavaScript代码4

www.jz123.cn  2010-09-27   来源:   中国建站    责任编辑(袁袁)    我要投递新闻

16.可以根据网页上的选项来确定页面颜色
<HTML>
<HEAD>
<TITLE>background.html</TITLE>
</HEAD>
<SCRIPT>
<!--

function bgChange(selObj) {
newColor = selObj.options[selObj.selectedIndex].text;
document.bgColor = newColor;
selObj.selectedIndex = -1;
}

//-->
</SCRIPT>
<BODY STYLE="font-family:Arial">
<B>Changing Background Colors</B>
<BR>
<FORM>
  <SELECT SIZE="8" onChange="bgChange(this);">
  <OPTION>Red
  <OPTION>Orange
  <OPTION>Yellow
  <OPTION>Green
  <OPTION>Blue
  <OPTION>Indigo
  <OPTION>Violet
  <OPTION>White
<OPTION>pink
  </SELECT>
</FORM>
</BODY>
</HTML>

17.将按钮的特征改变
<style type="text/CSS">
<!--
.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF

#CCCCCC #CCCCCC #CCCCFF}
.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin;

border-color: #CCFF99 #999999 #999999 #CCFF99}
-->
</style>
  本例按钮的代码如下:
<input type="submit" name="Submit" value="提 交" onmouseover="this.className='style2'"

onmouseout="this.className='style1'" class="style1">

18.改变按钮的图片.
<style type="text/css">
<!--
.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}
.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width:

60px; height: 22px}
-->
</style>
  本例的按钮代码如下:
<input type="submit" name="Submit2" value="提 交" onmouseover="this.className='style4'"

onmouseout="this.className='style3'" class="style3">

19.打印页面
<div align="center"><a class=content href="javascript:doPrint();">打印本稿</a></div>

20.可以直接写html语言
document.write("");

21.改变下拉框的颜色
<select name="classid"

onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)"

size="1" style="color:#008080;font-size: 9pt">

22.转至目标URL
window.location="http://guoguo"

23.传递该object的form
UpdateSN('guoqiang99267',this.form)
function UpdateSN(strValue,strForm)
{
  strForm.SignInName.value = strValue;
  return false;
}

24.文字标签
<label for="AltName4"><input name="AltName" type="RADIO" tabindex="931"  id="AltName4"

>guoqiang99859</label>

25.layer2为组件的ID,可以控制组件是否可见
document.all.item('Layer2').style.display = "block";
document.all.item('Layer2').style.display = "none";//

26.将页面加入favorite中
<script language=javascript>
<!--
function Addme(){
url = "http://your.site.address"; //你自己的主页地址
title = "Your Site Name"; //你自己的主页名称
window.external.AddFavorite(url,title);
-->
</script>//

27.过10秒自动关闭页面
< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >

28.可以比较字符的大小
char=post.charAt(i);
if(!('0'<=char&&char<='9'))

29.将字符转化为数字
month = parseInt(char)

30.点击value非空的选项时转向指定连接
<select onchange='if(this.value!="")window.open(this.value)' class="textinput">
    <option selected>主办单位</option>
    <option>-----------------</option>
    <option value="http://www.bjd.com.cn/">北京日报</option>
    <option value="http://www.ben.com.cn/">北京晚报</option>
</select>

31.改变背景颜色
<td width=* class=dp bgColor=#FAFBFC onmouseover="this.bgColor='#FFFFFF';"

onmouseout="this.bgColor='#FAFBFC';">

32.改变文字输入框的背景颜色
<style>
.input2 {background-image: url('../images/inputbg.gif');   font-size: 12px; background-color:

#D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
</style>
<input name=content type=text size="47" class="input2" maxlength="50">

33.改变水平线的特征
<hr size="0" noshade color="#C0C0C0">

34.传递参数的方式
<a href="vote.asp?CurPage=8&id=3488">8</a>

35.页内跳转
<a href="#1">1</a>
<a href="#2">2</a>
<a href="#3">3</a>
<a href="#4">4</a>
<a href="#5">5</a>
<a href="#6">6</a>
<a href="#7">7</a>
<a name="1">dfdf</a>
<a name="2">dfdf</a>//

36.两个按键一起按下
if(event.ctrlKey && window.event.keyCode==13)//


上一篇:常用JavaScript代码3 下一篇:常用JavaScript代码5

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图