<html>
<head>
<script type="text/javascript">
function test1(e){
window.alert("x=" + e.clientX + " y=" + e.clientY);
}
function test2(e){
window.alert("x=" + e.clientX + " y=" + e.clientY);
}
function test3(e){
window.alert(new Date().toLocaleString());
}
function test4(e){
if(e.value == "red"){
div1.style.backgroundColor = "red";
} else if (e.value == "black"){
div1.style.backgroundColor = "black";
}
}
</script>
</head>
<body>
<input type="button" onclick="test1(event)" value="button1">
<input type="button" onmouseover="test2(event)" value="button2">
<input type="button" onclick="test3(event)" value="button3">
<div id="div1" style="width: 400px; height: 300px; background-color: red"></div>
<input type="button" onclick="test4(this)" value="red">
<input type="button" onclick="test4(this)" value="black">
</body>
</html>
<html>
<head>
<script>
function test1(e){
window.alert("x="+e.clientX+"y="+e.clientY);
}
</script>
</head>
<body onmousedown="test1(event)">
</body>
</html>
//js如何访问css属性,来改变外观
<html>
<head>
<script>
function test3(e){
var pic=document.getElementById("pic");
if(e.value=="红色"){
pic.style.backgroundColor="red";
}
else if(e.value=="黑色"){
pic.style.backgroundColor="black";
}
}
</script>
</head>
<body >
<div id="pic" style="border:1;background-color:red;width:300px;height:300px"></div>
<input type="button" onclick="test3(this)" value="红色">
<input type="button" onclick="test3(this)" value="黑色">
</body>
</html>
event2.css
.style {
border:1;
background-color:red;
width:300px;
height:300px;
}
event2.html
<html>
<head>
<script>
function test3(e){
//取连接的第一个css文件的内容用0
var ocssRules=document.styleSheets[0].rules;
//从ocssRules取出你希望的样式
var style=ocssRules[0];//这里面的0表示event2.css文件中第一个规则
if(e.value=="黑色"){
style.style.backgroundColor="black";
}
else if(e.value=="红色"){
style.style.backgroundColor="red";
}
}
</script>
</head>
<body>
<div class="style"></div>
<input type="button" onclick="test3(this)" value="红色">
<input type="button" onclick="test3(this)" value="黑色">
</body>
</html>
<script language="javascript">
if(window.XMLHttpRequest)
{ //Mozilla, Safari, IE7,IE8
if(!window.ActiveXObject)
{ // Mozilla, Safari,
alert('Mozilla, Safari');
}
else
{
alert('IE7 .8');
}
}
else
{
alert('IE6');
}
</script>
<html>
<head>
function test(e){
window.alert("fss");
}
function test1(e){
window.alert("sfdsdf");
}
</script>
</head>
<body>
<div class="style"></div>
<input type="button" onclick="test(this),test1(this)" value="红色">
</body>
</html>
<html>
<script type="text/javascript">
function test(){
//window.alert("没有菜单");
return false;
}
function test2(){
//window.alert("全选不行");
return false;
}
</script>
</head>
<!--body元素响应oncontextmenu,onselectstart事件 -->
<body oncontextmenu="return test()" onselectstart="return test2()">
内容
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有