1.
location.search获得的是url中?后面的部分,包括?,比如?tn=sitehao123&word=
2.
如何获得JavaScript的Object对象的所有属性
for(i in obj) alert(i)
3.
正则匹配
'<img src="url" border=0> ',
'<img src=http://sds.sd/sd.jpg border=0> ',
'<img src="http://sds.sd/sd.jpg" border=0> ',
'<img src=/'http://sds.sd/sd.jpg/' border=0>
reg=/<IMG[^>]+?src=["']?([^"'>]+?)([ "'][^>]*)?[//]?>/ig
4.
<a id="x" href="abc.php?check=">xxx</a>
<script>
arr = new Array();
arr[0]="123";
a = document.getElementById("x");
a.href= a.href+arr[0];
</script>
5.
关闭前询问
<body onbeforeunload="return 'ok?'">
6.
fireEvent调用事件
<HTML>
<HEAD>
<SCRIPT>
function fnFireEvents()
{
oDiv.innerText = "The cursor has moved over me!";
//oButton.fireEvent("onclick");
oButton.click();
}
</SCRIPT>
<LINK REL="stylesheet" HREF="/workshop/samples/samples.css" TYPE="text/css">
</HEAD>
<BODY>
<h1>Using the fireEvent method</h1>
By moving the cursor over the DIV below, the button is clicked.
<P>
<div id="oDiv" onmouseover="fnFireEvents();" style="font-family: Comic Sans MS; font-size:14pt;color: #0033FF; background-color: oldlace; width: 250; height: 40; border-width: 5px; border-style: groove; border-color: burlywood;">
Mouse over this!
</div>
<p>
<BUTTON ID="oButton" ONCLICK="this.innerText='I have been clicked!'" >
Button</BUTTON>
</BODY>
</HTML>
7.
for (i=0;i<KeyWords.length;i++)
{
t=title.replace(new RegExp(KeyWords[i],"gi"),"<font color='red'>"+KeyWords[i]+"</font>" );
}
/gi可以这样对数组来说,如果按照原来写法出错
8.
<input type="button" value="test" onclick="alert('txt')">
我现在想能够alert出 t'x"t 该怎么写呢?
<input type="button" value="test" onclick="alert('t/'x"t')">
9.
插入图片
<iframe id="Editor" marginwidth=1 scrolling="auto" style="height:150px;width:100%;background-color:white;"></iframe>
<script>
var doc;
doc=document.frames.Editor.document;
doc.designMode = "On";
window.setTimeout('Editor.focus()',100);
function doInsertImage(){
Editor.focus();
doc.execCommand('InsertImage',false,'C:/Documents and Settings/Administrator/桌面/new.gif');
}
</script>
<button onclick="doInsertImage()">gogogogogo</button>
10.
<input type="text" name="textfield" id="text1" onpropertychange="aa(this)">
改变立即发生时间就用onpropertychange,change是失去焦点才触发
11
(function () {
var timeout = window.setTimeout;
window.setTimeout = function (a, b) {
var fun;
if ("function" == typeof a) {
var arg = Array.prototype.slice.call(arguments, 2);
fun = function () {
a.apply(null, arg);
};
} else {
fun = a;
}
return timeout(fun, b);
};
})();
可用来传递对象
12.
function getInfo(o){//取得坐标
var to=new Object();
to.left=to.right=to.top=to.bottom=0;
var twidth=o.offsetWidth;
var theight=o.offsetHeight;
while(o!=document.body){
to.left+=o.offsetLeft;
to.top+=o.offsetTop;
o=o.offsetParent;
}
to.right=to.left+twidth;
to.bottom=to.top+theight;
return to;
}
//返回一个对象
13
几个常用的css
<style >div{width:400px;overflow:hidden; word-break:no;white-space:nowrap;} </style>
<div id= "a " >
000000000 01 111111111222223333333333 4444444455555566666666667777777777888888888 8 9999999 999
</div >
word-break : normal | break-all | keep-all
white-space:normal|pre|nowrap
location.search获得的是url中?后面的部分,包括?,比如?tn=sitehao123&word=
2.
如何获得JavaScript的Object对象的所有属性
for(i in obj) alert(i)
3.
正则匹配
'<img src="url" border=0> ',
'<img src=http://sds.sd/sd.jpg border=0> ',
'<img src="http://sds.sd/sd.jpg" border=0> ',
'<img src=/'http://sds.sd/sd.jpg/' border=0>
reg=/<IMG[^>]+?src=["']?([^"'>]+?)([ "'][^>]*)?[//]?>/ig
4.
<a id="x" href="abc.php?check=">xxx</a>
<script>
arr = new Array();
arr[0]="123";
a = document.getElementById("x");
a.href= a.href+arr[0];
</script>
5.
关闭前询问
<body onbeforeunload="return 'ok?'">
6.
fireEvent调用事件
<HTML>
<HEAD>
<SCRIPT>
function fnFireEvents()
{
oDiv.innerText = "The cursor has moved over me!";
//oButton.fireEvent("onclick");
oButton.click();
}
</SCRIPT>
<LINK REL="stylesheet" HREF="/workshop/samples/samples.css" TYPE="text/css">
</HEAD>
<BODY>
<h1>Using the fireEvent method</h1>
By moving the cursor over the DIV below, the button is clicked.
<P>
<div id="oDiv" onmouseover="fnFireEvents();" style="font-family: Comic Sans MS; font-size:14pt;color: #0033FF; background-color: oldlace; width: 250; height: 40; border-width: 5px; border-style: groove; border-color: burlywood;">
Mouse over this!
</div>
<p>
<BUTTON ID="oButton" ONCLICK="this.innerText='I have been clicked!'" >
Button</BUTTON>
</BODY>
</HTML>
7.
for (i=0;i<KeyWords.length;i++)
{
t=title.replace(new RegExp(KeyWords[i],"gi"),"<font color='red'>"+KeyWords[i]+"</font>" );
}
/gi可以这样对数组来说,如果按照原来写法出错
8.
<input type="button" value="test" onclick="alert('txt')">
我现在想能够alert出 t'x"t 该怎么写呢?
<input type="button" value="test" onclick="alert('t/'x"t')">
9.
插入图片
<iframe id="Editor" marginwidth=1 scrolling="auto" style="height:150px;width:100%;background-color:white;"></iframe>
<script>
var doc;
doc=document.frames.Editor.document;
doc.designMode = "On";
window.setTimeout('Editor.focus()',100);
function doInsertImage(){
Editor.focus();
doc.execCommand('InsertImage',false,'C:/Documents and Settings/Administrator/桌面/new.gif');
}
</script>
<button onclick="doInsertImage()">gogogogogo</button>
10.
<input type="text" name="textfield" id="text1" onpropertychange="aa(this)">
改变立即发生时间就用onpropertychange,change是失去焦点才触发
11















可用来传递对象
12.
function getInfo(o){//取得坐标
var to=new Object();
to.left=to.right=to.top=to.bottom=0;
var twidth=o.offsetWidth;
var theight=o.offsetHeight;
while(o!=document.body){
to.left+=o.offsetLeft;
to.top+=o.offsetTop;
o=o.offsetParent;
}
to.right=to.left+twidth;
to.bottom=to.top+theight;
return to;
}
//返回一个对象
13
几个常用的css
<style >div{width:400px;overflow:hidden; word-break:no;white-space:nowrap;} </style>
<div id= "a " >
000000000 01 111111111222223333333333 4444444455555566666666667777777777888888888 8 9999999 999
</div >
word-break : normal | break-all | keep-all
white-space:normal|pre|nowrap
normal | White-space is ignored by the browser 浏览器将忽视空隙。 |
pre | White-space is preserved by the browser. Acts like the <pre> tag in HTML 空隙会被浏览器所保留。效果就类似于HTML中的<pre>标签 |
nowrap | The text will never wrap, it continues on the same line until a <br> tag is encountered 文字不会自动换行,它会在一行上显示,直到出现换行标签 |
<html>
<head>
<script type="text/javascript">
function setFixedTableLayout()
{
document.getElementById('myTable').style.tableLayout="fixed";
}
</script>
</head>
<body>
<table id="myTable" border="1" width="100%">
<col width="20%"><col width="40%"><col width="40%">
<tr>
<td>1000000000000000000000000000</td>
<td>10000000</td>
<td>100</td>
</tr>
</table>
<input type="button" onclick="setFixedTableLayout()"
value="Set fixed table layout">
</body>
</html>
word-wrap是控制换行的。
使用break-word时,是将强制换行。中文没有任何问题,英文语句也没问题。但是对于长串的英文,就不起作用。
break-word是控制是否断词的。
normal是默认情况,英文单词不被拆开。
break-all,是断开单词。在单词到边界时,下个字母自动到下一行。主要解决了长串英文的问题。
keep-all,是指Chinese, Japanese, and Korean不断词。即只用此时,不用word-wrap,中文就不会换行了。(英文语句正常。)
word-wrap:break-word不仅可以把超级长的英文单词截断,还可以根据空格区分英文单词,保持它的可读性。