Javascript 动态编程--动态设置网页元素是否可见,是否可用,改变大小,动态插入文字,进度条,动态改变背景例子
2007-12-08 20:47
886 查看
需求如下:
开始界面只有两个按钮,单击一个按钮,当前按钮不可用,并改变动态大小,另一个按钮不可见,
同时出来文字提示和进度条,要求只有一个页面,下面就实现这个功能。
进度条,通过动态背景实现,文字是通过id动态设置innerHTML实现
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>javascript动态改变示例</title>
</head>
<script language="JavaScript" type="text/javascript">
var pc = 0;
function pgload()
{
pc += 2;
ylpg.style.width = pc + "%";
time = setTimeout("pgload()",150);
if (pc > 100) { pc=0; }
}
function shangbao(obj)
{
//修改有关状态 --by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.12.08编写
obj.b_depute1.enable=false;
obj.b_depute1.value="正在上报,请稍候............";
obj.b_depute1.width=document.body.clientWidth;
obj.b_depute1.disabled=true;//不可用
obj.b_exit.style.display='none';//不可见
document.all["ylpg"].bgColor="#0000FF"; //改变背静
//obj.ylpg.style.bgColor=blue;
ylprogress.innerHTML = "<font face = '宋体' style='font-size:20pt' color='#FF0000'>正在上报,请稍候............ </FONT>";
//增加 end
pgload();
//要做的事情做在这里
//obj.submit();
}
</script>
<body leftmargin="5" topmargin="" onload="loadprogr()">
<form name="form1" method="post" action="">
<h1 align="center">闫磊欢迎你</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#AEDBF8">
<tr>
<td height="25" align="center" >
<input type="button" name="b_depute1" value="上报数据" onClick="javascript:shangbao(form1);" />
<input type="button" name="b_exit" value="退出" onClick="javascript:window.close();"/>
</td>
</tr>
</table>
<!--上报的提示信息 by yl-->
<table width=100% >
<tr>
<td align=center> <p id="ylprogress"></p></td>
</tr>
<tr>
<td align=center>
<center>
<table width=60% border=0><tr><td align=left>
<table id=ylpg height=18 width=0% bgcolor=white border=0><tr><td> </td></tr></table>
</td></tr></table>
</center>
</td></tr></table>
<!--上报的提示信息 by yl end-->
</form>
</body>
</html>
开始界面只有两个按钮,单击一个按钮,当前按钮不可用,并改变动态大小,另一个按钮不可见,
同时出来文字提示和进度条,要求只有一个页面,下面就实现这个功能。
进度条,通过动态背景实现,文字是通过id动态设置innerHTML实现
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>javascript动态改变示例</title>
</head>
<script language="JavaScript" type="text/javascript">
var pc = 0;
function pgload()
{
pc += 2;
ylpg.style.width = pc + "%";
time = setTimeout("pgload()",150);
if (pc > 100) { pc=0; }
}
function shangbao(obj)
{
//修改有关状态 --by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.12.08编写
obj.b_depute1.enable=false;
obj.b_depute1.value="正在上报,请稍候............";
obj.b_depute1.width=document.body.clientWidth;
obj.b_depute1.disabled=true;//不可用
obj.b_exit.style.display='none';//不可见
document.all["ylpg"].bgColor="#0000FF"; //改变背静
//obj.ylpg.style.bgColor=blue;
ylprogress.innerHTML = "<font face = '宋体' style='font-size:20pt' color='#FF0000'>正在上报,请稍候............ </FONT>";
//增加 end
pgload();
//要做的事情做在这里
//obj.submit();
}
</script>
<body leftmargin="5" topmargin="" onload="loadprogr()">
<form name="form1" method="post" action="">
<h1 align="center">闫磊欢迎你</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#AEDBF8">
<tr>
<td height="25" align="center" >
<input type="button" name="b_depute1" value="上报数据" onClick="javascript:shangbao(form1);" />
<input type="button" name="b_exit" value="退出" onClick="javascript:window.close();"/>
</td>
</tr>
</table>
<!--上报的提示信息 by yl-->
<table width=100% >
<tr>
<td align=center> <p id="ylprogress"></p></td>
</tr>
<tr>
<td align=center>
<center>
<table width=60% border=0><tr><td align=left>
<table id=ylpg height=18 width=0% bgcolor=white border=0><tr><td> </td></tr></table>
</td></tr></table>
</center>
</td></tr></table>
<!--上报的提示信息 by yl end-->
</form>
</body>
</html>
闫磊欢迎你
闫磊欢迎你
| |||||
相关文章推荐
- GridView中动态设置CommandField是否可用或可见的小例子
- GridView中动态设置CommandField是否可用或可见的小例子
- 3.1 Javascript:探索客户端-设置网页元素根据窗口比例调整位置与大小
- javascript自动改变文字大小和颜色的效果的小例子
- CSS改变网页中鼠标选中文字背景颜色例子
- 动态设置GridView自带CommandField是否可用或可见
- JS根据浏览器窗口大小实时动态改变网页文字大小的方法
- WebView改变网页文字大小、颜色,背景颜色
- WebView改变网页文字大小、颜色,背景颜色
- javascript自动改变文字大小和颜色的效果的小例子
- yui cookie Dynamically Change Text Size Using Javascript 动态设置字体大小,写入Cookie
- JTextPane例子,演示为文字设置字体、字号、样式、颜色、背景色和插入图片功能
- 设置网页正文文字大小 js
- (十一)javascript 动态改变元素的属性
- 怎样在网页的code behind里动态改变控件的背景颜色
- 动态改变表单元素的fieldLabel文字
- C#入门学习-----菜单应用(添加剂快捷方式、设置菜单项是否可用、修改菜单字体、创建级联菜单、级联菜单的动态合并)
- 在网页中设定根据元素大小伸缩的背景图
- JTextPane例子,演示为文字设置字体、字号、样式、颜色、背景色和插入图片功能
- 通过JavaScript使Div居中并随网页大小改变而改变