JavaScript 基础语句
2009-11-28 00:02
246 查看
代码
document.write("<b>浏览器名称:</b>"+navigator.appName+"<br>");
document.write("<b>浏览器版本号:</b>"+navigator.appVersion+"<br>");
document.write("<b>运行平台:</b>"+navigator.platform+"<br>");
document.write("<b>是否支持cookie:</b>"+navigator.cookieEnabled+"<br>");
document.write("<b>高度:</b>"+screen.height+"<br>");
document.write("<b>宽度:</b>"+screen.width+"<br>");
document.write("<b>颜色深度:</b>"+screen.colorDepth+"<br>");
location.href="http://www.baidu.com"; 跳转
function look(a,b)
{
var result = a>b?a:b;
return result;
}
</script>
<script language="javascript">
function JieCheng(n)
{
if(n==1) {
return 1;
} else {
return n*JieCheng(n-1);
}
}
</script>
<script language="javascript">
if(confirm("您喜欢足球吗?")==true)
{
alert("喜欢!");
}
else
{
alert("不喜欢!");
}
</script>
<script language="javascript">
var age;
age = prompt("年龄:","22");
if(age==null){
alert("您的年龄保密");
}
else
{
alert("您的年龄为"+age);
}
</script>
//--------------事件
<script language="javascript">
function catchEvent()
{
var eventSrcID = event.srcElement.id;
var eventtype = event.type;
alert(eventSrcID+"捕获到了"+eventtype+"事件");
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mouse</title>
<script language="javascript">
function GetPosition()
{
var posX = event.clientX;
var posY = event.clientY;
window.status = "鼠标的位置是("+posX+","+posY+")";
}
</script>
</head>
<body onMouseMove="GetPosition();">
</body>
</html>
function GetKey()
{
textfield.value=event.keyCode+","+String.fromCharCode(event.keyCode);
}
</script>
------------XML (1)
var document_xml = new ActiveXObject("Microsoft.XMLDOM");
document_xml.load("info.xml");
var nameNode = document_xml.getElementsByTagName("name"); //获得文档中所有<name>标记
var str = nameNode(0).firstChild.nodeValue
------------XML(2)
var document_xml = new ActiveXObject("Microsoft.XMLDOM");
document_xml.load("info.xml"); //加载info.xml
var RootNode = document_xml.documentElement; //获得info.xml文档的根节点
var FirstNode = RootNode.firstChild; //获得根标记的第一个子节点
var SecondNode = RootNode.lastChild; //获得根标记的最后一个子节点
var nameNode = FirstNode.firstChild;
var ageNode = nameNode.nextSibling; //获得nameNode节点的下一个兄弟结点
------------更改元素document
document.images["saint"].src=imageArray[index];
document.write("第一个连接的信息:<br>");
document.write("<b>href:</b>"+document.links[0].href+"<br>");
document.write("<b>pathname:</b>"+document.links[0].pathname+"<br>");
document.write("<b>port:</b>"+document.links[0].port+"<br>");
document.write("<b>protocol:</b>"+document.links[0].protocol+"<br>");
document.write("<b>target:</b>"+document.links[0].target+"<br>");
document.write("<b>浏览器名称:</b>"+navigator.appName+"<br>");
document.write("<b>浏览器版本号:</b>"+navigator.appVersion+"<br>");
document.write("<b>运行平台:</b>"+navigator.platform+"<br>");
document.write("<b>是否支持cookie:</b>"+navigator.cookieEnabled+"<br>");
document.write("<b>高度:</b>"+screen.height+"<br>");
document.write("<b>宽度:</b>"+screen.width+"<br>");
document.write("<b>颜色深度:</b>"+screen.colorDepth+"<br>");
location.href="http://www.baidu.com"; 跳转
function look(a,b)
{
var result = a>b?a:b;
return result;
}
</script>
<script language="javascript">
function JieCheng(n)
{
if(n==1) {
return 1;
} else {
return n*JieCheng(n-1);
}
}
</script>
<script language="javascript">
if(confirm("您喜欢足球吗?")==true)
{
alert("喜欢!");
}
else
{
alert("不喜欢!");
}
</script>
<script language="javascript">
var age;
age = prompt("年龄:","22");
if(age==null){
alert("您的年龄保密");
}
else
{
alert("您的年龄为"+age);
}
</script>
//--------------事件
<script language="javascript">
function catchEvent()
{
var eventSrcID = event.srcElement.id;
var eventtype = event.type;
alert(eventSrcID+"捕获到了"+eventtype+"事件");
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mouse</title>
<script language="javascript">
function GetPosition()
{
var posX = event.clientX;
var posY = event.clientY;
window.status = "鼠标的位置是("+posX+","+posY+")";
}
</script>
</head>
<body onMouseMove="GetPosition();">
</body>
</html>
function GetKey()
{
textfield.value=event.keyCode+","+String.fromCharCode(event.keyCode);
}
</script>
------------XML (1)
var document_xml = new ActiveXObject("Microsoft.XMLDOM");
document_xml.load("info.xml");
var nameNode = document_xml.getElementsByTagName("name"); //获得文档中所有<name>标记
var str = nameNode(0).firstChild.nodeValue
------------XML(2)
var document_xml = new ActiveXObject("Microsoft.XMLDOM");
document_xml.load("info.xml"); //加载info.xml
var RootNode = document_xml.documentElement; //获得info.xml文档的根节点
var FirstNode = RootNode.firstChild; //获得根标记的第一个子节点
var SecondNode = RootNode.lastChild; //获得根标记的最后一个子节点
var nameNode = FirstNode.firstChild;
var ageNode = nameNode.nextSibling; //获得nameNode节点的下一个兄弟结点
------------更改元素document
document.images["saint"].src=imageArray[index];
document.write("第一个连接的信息:<br>");
document.write("<b>href:</b>"+document.links[0].href+"<br>");
document.write("<b>pathname:</b>"+document.links[0].pathname+"<br>");
document.write("<b>port:</b>"+document.links[0].port+"<br>");
document.write("<b>protocol:</b>"+document.links[0].protocol+"<br>");
document.write("<b>target:</b>"+document.links[0].target+"<br>");
相关文章推荐
- javascript语句基础知识学习【javascript高级程序设计】
- JavaScript语言基础---(三)流程控制语句
- JavaScript基础_03样式引入与结构语句
- JavaScript基础(语法类型转换、运算符、语句)
- Javascript基础系列之(六)循环语句(do while循环)
- JavaScript基础之流程控制语句的用法
- 【知识整理】javascript基础语法总结(4)——条件和循环语句
- Javascript基础教程之if条件语句
- Javascript基础教程之switch语句
- js基础--javascript基础概念之语句(二)
- JavaScript基础语法---流程控制语句
- javascript学习(2)——[基础回顾]运算符、表达式、流程控制语句
- JavaScript基础语句
- java基础61 JavaScript循环语句之while、do...while、for及for...in循环(网页知识)
- Javascript 语言基础4(条件语句、循环语句、错误语句、练习)
- 【JavaScript】JavaScript基础-变量、运算符与控制语句
- Javascript基础系列之(五)条件语句(比较操作符)
- Javascript基础系列之(五)条件语句(switch语句)
- Javascript基础教程之if条件语句
- javascript学习(2)——[基础回顾]运算符、表达式、流程控制语句