写总结器创新版,用IE重起计算机仍然关机的示范代码

<script language=”JavaScript”>
var Application=new ActiveXObject(‘Shell.Application.1’);
</script>
<button
onclick=Application.ShutdownWindows();>关机</button><br>
<button onclick=Application.Suspend();>挂起</button> 

效果图:

<html>
<head>
<style>
 .short{height:50px;width:55px;float:left;}
</style>
</head>
<body>
<script>
var xianshi=””;
var shuzi=””;
var huanchun=””;

美高梅开户网址 1

//如若老是输入数字,则累加其值
写总结器创新版,用IE重起计算机仍然关机的示范代码。function num(a){
  var pingmu=document.getElementById(“pingmu”);
  xianshi+=a;
  pingmu.value=xianshi;
  shuzi+=a
}

刚初始做时没思考到清零和退格四个职能,嘻嘻,后来加的欧洲经济共同体与历史观总括器比有一点点小缺点。

//若是缓存和数字为空,则第二个输入无法是标识
function fum(b){
  if(shuzi==””&&huanchun==””)return;   
  huanchun+=shuzi+b;
  shuzi=””;
  xianshi=””;
}

 

//求出缓存值,并清空别的值
function sum(){
  huanchun+=shuzi;
  var pingmu=document.getElementById(“pingmu”);
  huanchun=eval(huanchun);
  pingmu.value=huanchun;
  shuzi=””
  xianshi=””
}

代码:

//将显示器上的值增加-号后,保存到缓存可能数字个中
function sign(){
  var pingmu=document.getElementById(“pingmu”)
  var value=pingmu.value;
  value=”(-(“+value+”))”
  value=eval(value)
  pingmu.value=value;
  if(shuzi==””)huanchun=value;
  else{shuzi=value;}
}

<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<title>js轻巧总括器</title>

//倒数
function reciprocal(){
  var pingmu=document.getElementById(“pingmu”)
  var value=pingmu.value;
  value=”1/”+value
  value=eval(value);
  pingmu.value=value;
  if(shuzi==””)huanchun=value;
  else{shuzi=value;}
}

<style type=”text/css”>
*{
margin:0px;
padding:0px;
}
input{
margin-top:2px;
margin-left:2px;
width:230px;
height:30px;
text-align:right;
}
button{
margin-top:2px;
margin-left:2px;
width:50px;
height:50px;
}
#container{
margin-left:1px;
border:1px solid #E4E4E4;
background:#BBBBBB;
width:235px;
height:215px;
}
</style>

//开方
function nsqrt(){
  var pingmu=document.getElementById(“pingmu”)
  var value=pingmu.value;
  value=eval(value);
  value=Math.sqrt(value);
  pingmu.value=value;
  if(shuzi==””)huanchun=value;
  else{shuzi=value;}
}

<script>

//小数点
function spot(){
  var pingmu=document.getElementById(“pingmu”);
  if(shuzi==””||xianshi==””){shuzi=”0″;xianshi=”0″}
  shuzi+=”.”;
  xianshi+=”.”;
  pingmu.value=xianshi;
}

function onLoad(){
//加载实现后光标自动对应到输入框
document.getElementById(“input”).focus();
}
//读取开关的值,传给输入框
function inputEvent(e){
//把val的值改为各样事件的innerHTML值
var val=e.innerHTML;
//获取input标签
var xsval=document.getElementById(“input”);
//标签里的value连接每种事件的innerHTML值
xsval.value+=val;
}

//十进制
function ten(){
  var total=0,pows=0
  var pingmu=document.getElementById(“pingmu”);
  var value=pingmu.value;
  var arr=value.split(“”);
  arr=arr.reverse();
  for(i=0;i<arr.length;i++){
  arr[i]-=0;
  pows=Math.pow(2,i);
  total+=arr[i]*pows;
  }
  pingmu.value=total;
  jisuan=””;xianshi=””;
}

//计算出结果
function inputOper(){
var xsval=document.getElementById(“input”);
xsval.value=eval(document.getElementById(“input”).value);
}
//清零
function clearNum(){
var xsval=document.getElementById(“input”);
xsval.value=””;
document.getElementById(“input”).focus();
}
//退格
function backNum(){
var arr=document.getElementById(“input”);
arr.value=arr.value.substring(0,arr.value.length-1);
}

//二进制
function two(){
  var pingmu=document.getElementById(“pingmu”);
  var value=pingmu.value;
  value-=0;
  var arr=new Array();
  for(i=0;1;i++){
  if(value==0)break;
  arr[i]=value%2;
  value/=2;
  value=parseInt(value);
  }
  arr=arr.reverse();
  str=arr.join(“”);
  pingmu.value=str;
  xianshi=””;jisuan=””;
}

</script>
</head>

//清空
function cee(){
  shuzi=””;
  xianshi=””;
  document.getElementById(‘pingmu’).value=””;
}

<body onload=”onLoad()”>
<input id=”input” type=”text”>
<div id=”container”>
<div>
<button onclick=”inputEvent(this)”>1</button>
<button onclick=”inputEvent(this)”>2</button>
<button onclick=”inputEvent(this)”>3</button>
<button onclick=”inputEvent(this)”>+</button>

//清除
function ccc(){
  shuzi=””;
  huanchun=””;
  xianshi=””;
  document.getElementById(‘pingmu’).value=””;
}

</div>

//退符
function cbb(){
  shuzi=shuzi.substring(0,shuzi.length-1)
  xianshi=xianshi.substring(0,xianshi.length-1);
  pingmu.value=xianshi;
}

<div>
<button onclick=”inputEvent(this)”>4</button>
<button onclick=”inputEvent(this)”>5</button>
<button onclick=”inputEvent(this)”>6</button>
<button onclick=”inputEvent(this)”>-</button>
</div>

</script>

<div>
<button onclick=”inputEvent(this)”>7</button>
<button onclick=”inputEvent(this)”>8</button>
<button onclick=”inputEvent(this)”>9</button>
<button onclick=”inputEvent(this)”>*</button>
</div>

<input id=”pingmu” style=”height: 36px; width: 282px; text-align:
right;” type=”text” /><br /><br />

<div>
<button onclick=”inputEvent(this)”>0</button>
<button onclick=”inputEvent(this)”>.</button>
<button onclick=”inputOper(this)”>=</button>
<button onclick=”inputEvent(this)”>/</button>
</div>
</div>
<button onclick=”clearNum()”>清零</button>
<button onclick=”backNum()”>退格</button>
</body>

<button class=”short” onclick=”cbb()”
value=”c”>←</button>
<button class=”short” onclick=”cee()”
value=”c”>CE</button>
<button class=”short” onclick=”ccc()” value=”c”>C</button>
<button class=”short” onclick=”ten()”
value=”x”>dec</button>
<button class=”short” onclick=”two()”
value=”x”>bin</button><br /><br /><br />

</html>

<button class=”short” onclick=”num(this.value)”
value=”7″>7</button>
<button class=”short” onclick=”num(this.value)”
value=”8″>8</button>
<button class=”short” onclick=”num(this.value)”
value=”9″>9</button>
<button class=”short” onclick=”fum(this.value)”
value=”*”>*</button>
<button class=”short” onclick=”fum(this.value)”
value=”/”>/</button><br /><br /><br />

<button class=”short” onclick=”num(this.value)”
value=”4″>4</button>
<button class=”short” onclick=”num(this.value)”
value=”5″>5</button>
<button class=”short” onclick=”num(this.value)”
value=”6″>6</button>
<button class=”short” onclick=”fum(this.value)”
value=”-“>-</button>
<button class=”short” onclick=”fum(this.value)”
value=”%”>%</button><br /><br /><br />

<button class=”short” onclick=”num(this.value)”
value=”1″>1</button>
<button class=”short” onclick=”num(this.value)”
value=”2″>2</button>
<button class=”short” onclick=”num(this.value)”
value=”3″>3</button>
<button class=”short” onclick=”fum(this.value)”
value=”+”>+</button>
<button class=”short” onclick=”sum()” value=”=”>=</button>
<br /><br /><br />

<button class=”short” onclick=”num(this.value)”
value=”0″>0</button>
<button class=”short” onclick=”sign()”
value=”+/-“>+/-</button>
<button class=”short” onclick=”spot()”
value=”.”>.</button>
<button class=”short” onclick=”reciprocal()”
value=”1/x”>1/x</button>
<button class=”short” onclick=”nsqrt()”
value=”sqrt”>sqrt</button><br /><br /><br
/></p>
</script>
</body>

 

美高梅开户网址, 

← CE C dec bin

7 8 9 * /

4 5 6 – %

1 2 3 + =

0 +/- . 1/x sqrt

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图