替换页面文本
待替换文本
<script language="javascript" type="text/javascript"> var str = "替换的文本内容"; document.getElementById("pn").innerHTML = str; } </script>
timer函数
时间
<script language="javascript" type="text/javascript"> cd(); setInterval(cd,1000); function cd() { var oDate = new Date(); var str = oDate.getHours() +":"+oDate.getMinutes()+":"+oDate.getSeconds(); document.getElementById("pn").innerHTML = "time:"+str; } </script>
高考倒计时
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>高考倒计时</title>
<meta name="viewport" content="target-densitydpi=device-dpi, width=480px, user-scalable=no" />
<style type="text/css">
.jsfont{
font-size: 6rem;
color:crimson;
text-shadow:5px 2px 6px #000 ;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
}
.jsTitlfont{
font-size:4ex;
color:rebeccapurple;
text-shadow:2px 1px 3px #000 ;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
}
.roundZoneDark {
border: 4px solid crimson;
background-color:crimson;
font-size:4rem;
color:white;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
-moz-border-radius: 15px; /* Gecko browsers */
-webkit-border-radius: 15px; /* Webkit browsers */
border-radius:15px; /* W3C syntax */
box-shadow:5px 2px 6px #000 ;
}
</style>
<body >
<table width=98%>
<tr><td align="center"><div class="roundZoneDark">高考倒计时</div></td></tr>
<tr><td align="center"><div class="jsfont"><p id="pn" >剩余时间</p></div></td></tr>
<script language="javascript" type="text/javascript">
var dateGK = new Date(2022,6,6,1,1,1,1);
cd();
setInterval(cd,1000);
function cd()
{
var oDate = new Date();
var str = oDate.getHours() +":"+oDate.getMinutes()+":"+oDate.getSeconds();
var gkDay = parseInt( (dateGK-oDate)/24/3600/1000);
var gkHour = parseInt( (dateGK-oDate)/3600/1000%24);
var gkmin = parseInt( (dateGK-oDate)/1000/60%60);
var gksencond = parseInt( (dateGK-oDate)/1000%60);
document.getElementById("pn").innerHTML = gkDay.toString()+"天"+gkHour.toString()+"时"+gkmin.toString()+"分"+gksencond.toString()+"秒";
}
</script>
</table>
</body>
</html>
响应按钮点击
<input type="button" value="java test" onclick="startflag()" class="roundZone">
<script language="javascript" type="text/javascript"> function startflag() { document.getElementById("pn").innerHTML = "button click"; } </script>
获取用户输入一项信息
html部分
<input type="button" name="button" value="输入姓名" onclick="check()" class="button"> <a id="iname"></a>
script 代码
<script lang="javascript"> function check() { var name = prompt("请输入你的名字:"); document.getElementById("iname").innerHTML = name; } </script>
调用c#函数
document.getElementById("Button1").click();
访问c#文本框内容
var tel = prompt("请输入你的电话号码:"); document.getElementById("TextBox3").value = tel;
c#label的Text不能访问,可以访问C#button的事件更改label的内容