js

为了很好的调试javascript

出现问题一:

 Internet Explorer己限制此网页进行可以访问计算机的脚本或ActiveX控件。请单击这里获取选项

-------------------------------------------------------------------------------------

解决方案:

工具->internet 选项-》高级->允许活动内容在我的计算机上的文件中执行。 

你要选 中它,而不是不选 它!!!
工具——Internet选项——安全——自定义级别——将ActiveX控件设置成停用即可。 
其实只要你访问的是本地文件就会有那种提示。
MM_openBrWindow('../../../../../../../桌面/me.jpg'
你编写网页时关键就是你这句是本地路径。

出现问题二:

为了有利于保护安全性,Internet 已限制网页运行可以访问计算机的脚本……”

--------------------------------------------------------------------------

解决方案:

开始>运行>输入“gpedit.msc”回车,
打开组策略编辑器。依次展开本地计算机策略>计算机配置>管理模块>Windows组件>Internet Explorer,
在右边的窗口中找到“关闭安全设置检查功能”策略项,
双击此项,在“设置”选项中选择“已启用”。

搞定!

1、

<html>
<head>
<title>标题</title>
<script>

function sayhello(){
alert("hello ,this is the first ");
}
</script>
</head>

<body>
<input type="button" value="say" onclick="sayhello()"/>
</body>


</html>

2、

<html>
<head>
<title>标题</title>
<script>

function sayhello(){
confirm("hello ,this is the first ");
}
</script>
</head>

<body>
<input type="button" value="say" onclick="sayhello()"/>
</body>


</html>

3

<html>
<head>
<title>标题</title>
<script>
myNewObject=new Object();
myNewObject.info='i am a new object';

function myFunc(){
alert(this.info);
}
myNewObject.showInfo=myFunc;
</script>
</head>

<body>
<input type="button" value="good shouinfo call" onclick="myNewObject.showInfo()"/>
<input type="button" value="myFunc() call" onclick="myFunc()" />
<input type="button" value="Bad showInfo call" onclick="showInfo()" />
</body>


</html>

4、传递参数

<html>
<head>
<title>标题</title>
<script>
function cube(x){

alert(x*x*x);
}

</script>
</head>


<body>
<input type="button" id="6" button" value="left" onclick = "cube(this.id)"/>


</body>


</html>

5 传递参数例子

<html>
<head>
<title>标题</title>
<script>
function buttonReport(buttonId,buttonName,buttonValue){
var userMessage1="Button id:"+buttonId+" ";
var userMessage2="Button name:"+buttonName+" ";
var userMessage3="Button value:"+buttonValue;
alert(userMessage1+ userMessage2 + userMessage3);
}

</script>
</head>


<body>
<input type="button" id="id1" name="left  button" value="left" onclick = "buttonReport(this.id,this.name,this.value)"/>
<input type="button" id="id2" name="center button" value="center" onclick="buttonReport(this.id,this.name,this.value)"/>
<input type="button" id="id3" name="right button" value="right" onclick="buttonReport(this.id,this.name,this.value)"/>

</body>


</html>

6、全局变量与局部变量

<html>
<head>
<title>标题</title>
</head>
<body>
<script>
var a=10;
var b=10;

function showVars(){
var a=30;
 b=30;//改变了全局变量的值
return "loacal variable 'a'="+a+" Global variable 'b'="+b;
}
var message=showVars();
alert(message+" Gloabal variable 'a'="+a +" "+"全局变量改变了b="+b);
</script>

</body>


</html>

原文地址:https://www.cnblogs.com/bluewelkin/p/3813174.html