感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>demo</title>
<style type="text/css">
html{
height:100%;
}
body{
#mydiv{
width:300px;
height:300px;
background-color: #ff7400;
#ctxMenu{
list-style-type: none;
position: absolute;
padding:0px;
border:1px solid #000;
visibility: hidden;
</style>
</head>
<body>
<div id="mydiv"></div>
<h2 id="show"></h2>
<input type="text"id="txt"><span id="help"></span>
<ul id="ctxMenu">
<li>上传</li>
<li>下载</li>
<li>新建</li>
<li>取消</li>
</ul>
<script type="text/javascript">
var $=function(id){
return document.getElementById(id);
};
var h2=$("show");
var ctx=$("ctxMenu");
var txt=$("txt");
var help=$("help");
/*
txt.onfocus=function(){
help.innerHTML="请输入金额";
txt.onkeydown=function(event){
help.innerHTML="";
var code=event.keyCode;
if(!(code>=48&&code<=57||code>=96&&code<=105||code==46||code==8||code==13||code==37||code==39||code==110||code==190)){
event.preventDefault();
*/
document.body.oncontextmenu=function(event){
var x=event.pageX;
var y=event.pageY;
ctx.style.left=x+"px";
ctx.style.top=y+"px";
ctx.style.visibility="visible";
document.body.onclick=function(){
ctx.style.visibility="hidden";
document.body.onmousemove=function(event){
h2.innerHTML=x+":"+y;
window.onbeforeunload=function(){
var v=$("txt").value;
if(v){
return "";
$("mydiv").onclick=function(){
$("show").innerHTML="click";
$("mydiv").ondblclick=function(){
$("show").innerHTML="dblclick";
$("mydiv").onmouseover=function(){
$("show").innerHTML="mouseover";
this.style.backgroundColor="#2d2d2d";
$("mydiv").onmouseout=function(){
$("show").innerHTML="mouseout";
this.style.backgroundColor="pink";
</script>
</body>
</html>
输入 JavaScript 代码……
xxxxxxxxxx
输入 CSS 代码……