JavaScript就这么回事 (JS基础知识整理)
1 创建脚本块
引用内容程序代码
<script language=”JavaScript”>
JavaScript 代码写在这里面
</script>
2 隐藏脚本代码
引用内容程序代码
<script language=”JavaScript”>
<!--
document.write(“Hello”);
// -->
</script>
在不支持JavaScript的浏览器中将不执行相关代码
3 浏览器不支持的时候显示
引用内容程序代码
<noscript>
Hello to the non-JavaScript browser.
</noscript>
4 链接外部脚本文件
引用内容程序代码
<script language=”JavaScript” src="/”filename.js"”></script>
5 注释脚本
引用内容程序代码
// This is a comment
document.write(“Hello”); // This is a comment
/*
All of this
is a comment
*/
6 输出到浏览器
引用内容程序代码
document.write(“<strong>Hello</strong>”);
7 定义变量
引用内容程序代码
var myVariable = “some value”;
8 字符串相加
引用内容程序代码
var myString = “String1” + “String2”;
9 字符串搜索
引用内容程序代码
<script language=”JavaScript”>
<!--
var myVariable = “Hello there”;
var therePlace = myVariable.search(“there”);
document.write(therePlace);
// -->
</script>
10 字符串替换
引用内容程序代码
thisVar.replace(“Monday”,”Friday”);
11 格式化字串
引用内容程序代码
<script language=”JavaScript”>
<!--
var myVariable = “Hello there”;
document.write(myVariable.big() + “<br>”);
document.write(myVariable.blink() + “<br>”);
document.write(myVariable.bold() + “<br>”);
document.write(myVariable.fixed() + “<br>”);
document.write(myVariable.fontcolor(“red”) + “<br>”);
document.write(myVariable.fontsize(“18pt”) + “<br>”);
document.write(myVariable.
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<script language="javascript">
<!--
String.prototype.replaceAll = stringReplaceAll;
function stringReplaceAll(AFindText,ARepText){
raRegExp = new RegExp(AFindText,"g");
return this.replace(raRegExp,ARepText)
}
var content = "%sfasf%sfd%asdfsadf%1111%"
// 把 所有的 % 替换为 #
......
1. 短时间,形如 (13:04:06)
function isTime(str)
{
var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/);
if (a == null) {alert('输入的参数不是时间格式'); return false;}
if (a[1]>24 || a[3]>60 || a[4]>60)
{
alert("时间格式不对");
return false
}
return true;
}
2. 短 ......
一、功能实现核心:FileSystemObject 对象
要在javascript中实现文件操作功能,主要就是依靠FileSystemobject对象。
二、FileSystemObject编程
使用FileSystemObject 对象进行编程很简单,一般要经过如下的步骤: 创建FileSystemObject对象、应用相关方法、访问对象相关属性 。 ......
本文是对《AJAX动态网页信息提取原理》
的补充,前文总结了两种AJAX网页文字的抓取方法:
网页文字在加载HTML文档(document)的时候用Javascript代码获取和展现,此Javascript代码在发送load事件之前运行,那么接收到load事件表示所有的内容都加载完了
网页文字在加载完HTML文档(document)后在某个时刻用Javascript ......