Q:http://www.csdn.net/expert/Topicview1.asp?id=857893我用如下代码,生成新窗口。var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>");
doc.writeln("<body>中文内容</body></html>");但中文都变成了? 为什么?
操作系统为英文win2k ie6 系统可以正常显示中文网页
A: 不知道算不算已经解决了
<script>
function trans(str){
var reg=/[^\x00-\xff]/g
var idx=0,ret="";
while(reg.exec(str)){
ret+=str.substring(idx,RegExp.lastIndex-1)+"&#"+RegExp.lastMatch.charCodeAt(0)+";"
idx=RegExp.lastIndex;
}
ret+=str.substring(idx)
return(ret);
}var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln(trans("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>"));
doc.writeln(trans("<body>中文内容</body></html>"));
</script>
var doc = NewWindow.document;doc.open();
doc.writeln("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>");
doc.writeln("<body>中文内容</body></html>");但中文都变成了? 为什么?
操作系统为英文win2k ie6 系统可以正常显示中文网页
A: 不知道算不算已经解决了
<script>
function trans(str){
var reg=/[^\x00-\xff]/g
var idx=0,ret="";
while(reg.exec(str)){
ret+=str.substring(idx,RegExp.lastIndex-1)+"&#"+RegExp.lastMatch.charCodeAt(0)+";"
idx=RegExp.lastIndex;
}
ret+=str.substring(idx)
return(ret);
}var NewWindow = window.open("about:blank", "displayNode");
var doc = NewWindow.document;doc.open();
doc.writeln(trans("<html><head><meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=gb2312\"><title>中文标题</title></head>"));
doc.writeln(trans("<body>中文内容</body></html>"));
</script>
http://www.blueidea.com/user/qswh/css2.chmwsh文档:
http://www.blueidea.com/user/qswh/wsh.chmjs文档:
http://www.blueidea.com/user/win1st/other/jsdoc.exe
Internet选项->安全->可信任站点->自定义级别->对没有标志为安全的ActiveX进行初始化和脚本运行
http://www.blueidea.com/bbs/newsdetail.asp?id=346635HTTP:
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
ASP
response.expires=0
response.addHeader("pragma","no-cache")
response.addHeader("Cache-Control","no-cache, must-revalidate")PHP
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
请问JavaScript中有没有可以精确到某一位的四舍五入的方法?
例如MyRound(n,m),意为:将数字n精确至小数点后m位<script>
function MyRound(n,m){
//IE5.5以下
with(Math)return round(n*pow(10,m))/pow(10,m)
}
function MyRound6(n,m){
//IE5.5以上
return n.toFixed(m);
}
alert(MyRound(1.245,2));
alert(MyRound6(1.245,2));
</script>
var XH = new ActiveXObject ("Microsoft.XMLHTTP");
XH.Open("get", "link_select_get.php?depart="+val, false);
XH.Send("");
alert(XH.responseText);A: bytes2bstr(XH.responseBody)<script language=vbs>
function bytes2bstr(vin)
dim i,strreturn
strreturn = ""
for i = 1 to lenb(vin)
thischarcode = ascb(midb(vin,i,1))
if thischarcode < &h80 then
strreturn = strreturn & chr(thischarcode)
else
nextcharcode = ascb(midb(vin,i+1,1))
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
i = i + 1
end if
next
bytes2bstr = strreturn
end function
</script><script language=jscript>
var XH = new ActiveXObject ("Microsoft.XMLHTTP");
XH.Open("get", "link_select_get.php?depart="+val, false);
XH.Send("");
alert(bytes2bstr(XH.responseBody));
</script>
在html中有一个input的数组,需要知道当前正在输入的input控件在此数组中的下标A: 利用它和parentElement的sourceIndex差别
<script>function show(e){window.status=e.sourceIndex-e.parentElement.sourceIndex}</script>
var a=12;
var b=0.2作如下运算:
parseFloat(a)*parseFloat(b)
得出的是2.4000000000000003如何才能只得到2.4?A:
<script>
function qswhMul(p1,p2){
/********(qiushuiwuhen 2002-07-05)************/
var e1=0,e2=0,s1=String(p1),s2=String(p2);
try{e1=s1.split(".")[1].length}catch(e){}
try{e2=s2.split(".")[1].length}catch(e){}
r=Number(s1.replace(".",""))*Number(s2.replace(".",""))
return r/Math.pow(10,e1+e2)
}
alert(qswhMul(12,0.2));
alert(qswhMul(1.8,0.2));
</script>
我能用javascript来合计一个表格的一列或一行并显示在最后一列或最后一行吗?遍历即可
<table id=demo border=1>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>
</table>
<script>
y=demo.rows.length;
x=demo.rows[0].cells.length;
if(confirm("行还是列?")){
for(i=0;i<y;i++){
sum=0;for(j=0;j<x;j++)sum+=Number(demo.rows[i].cells[j].innerText);
demo.rows[i].insertCell().innerText="该行和"+sum
}
}else{
row=demo.insertRow()
for(j=0;j<x;j++){
sum=0;for(i=0;i<y;i++)sum+=Number(demo.rows[i].cells[j].innerText);
row.insertCell().innerText="该列和"+sum
}
}
</script>
A:
hasOwnProperty 要求 版本 5.5,
instanceof 要求 版本 5
constructor 要求 版本 2<script>
function chkArr(o){return typeof(o.length)!="undefined"}
function isArr(o){return o.constructor==Array}var arr=[1,2,3,4]
var obj={1:2,3:4}
alert(chkArr(arr))
alert(chkArr(obj))
alert(isArr(arr))
alert(isArr(obj))
</script>
with(event)if(clientX>document.body.clientWidth &&clientY<0||altKey)
return "Are u sure?"
}
thanks秋水!~
秋水是姐姐吗?如果是大家都去追她了,hehe。此帖不收藏简直就是浪费
<script>
str="[apple]hehe[/apple]xixi[apple]hehe[/apple]"
alert("贪婪匹配的结果:"+str.replace(/\[apple\](.+)\[\/apple\]/g,"<a>$1</a>"))
alert("非贪婪匹配的结果:"+str.replace(/\[apple\](.+?)\[\/apple\]/g,"<a>$1</a>"))
</script>
<script>
str="bananaxixiapple"
str=str.replace(/\[url\](.+?)\[\/url\]/g,function($0,$1){return ($1).indexOf("apple")==-1?"<a>"+$1+"</a>":""+$1+""})alert("结果:"+str)
</script>
我怎么知道 tabIndex等于某个值的元素是什么?
我怎么将焦点focus到指定tabIndex等于某个值得元素上??
1.onfocus
<input name=input1 onfocus=window.status=name>
<input name=input2 onfocus=window.status=name>
<input name=input3 onfocus=window.status=name>
<input name=input4 onfocus=window.status=name>2.activeElement
<input name=input1>
<input name=input2>
<input name=input3>
<input name=input4>
<script>
function getAct(){window.status=document.activeElement.name}
setInterval(getAct,100)
</script>
如下:<PUBLIC:PROPERTY NAME="isFocus" GET="_getFocus"/>
<PUBLIC:ATTACH EVENT="onfocus" ONEVENT="_focus()" />
<PUBLIC:ATTACH EVENT="onblur" ONEVENT="_blur()" />
<SCRIPT LANGUAGE="JScript">
var isFocus=false;
function _getFocus()
{
return isFocus;
}
function _focus()
{
isFocus=true;
}
function _blur()
{
isFocus=false;
}
</SCRIPT>存为a.htc
如下使用:<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY onbeforeunload="alert(xxx.isFocus||xxx.isFocus);return false" ondblclick="alert(xxx.isFocus||xxx.isFocus)">
<P>
<button id=xxx style="behavior:url(a.htc)" onclick="alert(xxx.isFocus)">open</button>
<button id=yyy style="behavior:url(a.htc)" onclick="alert(yyy.isFocus)">leave</button>
</BODY>
</HTML>
1、我如何知道指定tabIndex的是哪个元素
2、我怎么知道tabIndex最大是多少?
3、当我用如下脚本:
if(window.event.keyCode == 13){
window.event.keyCode=9;
}
将ENTER键实现TAB键的功能后,当焦点在最后一个元素时,
如果再按下ENTER键,焦点从页面上消失了,
焦点这时候在那里?如何让焦点再回到页面上
一般用sourceIndex,每个控件都有,系统自带
tabIndex是用来手动调节tab顺序的,人工设置所以我不建议通过tabIndex,
<input><input><input><input><input>
<script>
function document.onkeydown(){
with(window.event){
if((keyCode==13)&&(document.all(srcElement.sourceIndex+1).tagName=="INPUT"))keyCode=9;
window.status="soruceIndex:"+srcElement.sourceIndex+" tabIndex:"+srcElement.tabIndex
}
}
</script>
1.Adodb.Stream需要IIS5才自带
2.可能你没有权限或被管理员禁止了