<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<script>
var sInitColor = null;
function foreColor()
{
if (sInitColor == null)
var sColor = document.all.dlgHelper.ChooseColorDlg();
else
var sColor = document.all.dlgHelper.ChooseColorDlg(sInitColor);
sColor = sColor.toString(16);
if (sColor.length < 6) {
var sTempString = "000000".substring(0,6-sColor.length);
sColor = sTempString.concat(sColor);
}
sColor = "#" + sColor
x.value=sColor
}
</script>
<input id=x><input type=button onclick="foreColor()">
<script>
var sInitColor = null;
function foreColor()
{
if (sInitColor == null)
var sColor = document.all.dlgHelper.ChooseColorDlg();
else
var sColor = document.all.dlgHelper.ChooseColorDlg(sInitColor);
sColor = sColor.toString(16);
if (sColor.length < 6) {
var sTempString = "000000".substring(0,6-sColor.length);
sColor = sTempString.concat(sColor);
}
sColor = "#" + sColor
x.value=sColor
}
</script>
<input id=x><input type=button onclick="foreColor()">
下午一直搜索来着,大多都不好用
你这个简介又实用,谢了
稍后结贴
<object id=dlgHelper classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px">
</object>
<object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
<PARAM NAME="LPKPath" VALUE="comdlg.lpk">
</object>
<object id="cDialog" width="0px" height="0px" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
</object>
<label id=z>字体:</label><select id=zt style="width:200" onchange="z.style.fontFamily = this.options[this.selectedIndex].text"></select><br>
<label id=l1>颜色:</label><input type=button onclick="changeColor();" value="chage color">
<label>信息:</label><textarea id=xx style="background-color:red;width:100;height:100">nothing</textarea><input type=button value=save onclick="saveDoc()"><input type=button value=load onclick="loadDoc()">
<input type=button value=printer onclick="print()">
<script>
function Init()
{
var i=dlgHelper.fonts.count;
var opt="";
for(var j=1;j<i;j++)
{
opt+="<option>"+dlgHelper.fonts(j)+"</option>";
var o=document.createElement("option");
zt.insertAdjacentElement("afterBegin",o);
o.text=dlgHelper.fonts(j);
}
}
function changeColor(sInitColor)
{
if(sInitColor==null)
var sColor=dlgHelper.ChooseColorDlg();
else
var sColor=dlgHelper.ChooseColorDlg(sInitColor);
sColor=sColor.toString(16);
if(sColor.length<6)
{
var sTempString="000000".substring(0,6-sColor.length);
sColor=sTempString.concat(sColor);
}
l1.style.backgroundColor=sColor;
}
function loadDoc()
{
cDialog.CancelError=true;
try{
cDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt";
cDialog.ShowOpen();
var fso=new ActiveXObject("Scripting.FileSystemObject");
var reading=1;
var f=fso.OpenTextFile(cDialog.filename,reading);
alert(f);
var r=f.ReadAll();
f.close();
xx.value=r;
}catch(e){}
}
function saveDoc()
{
cDialog.CancelError=true;
try{
cDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt";
cDialog.ShowSave();
var fso=new ActiveXObject("Scripting.FileSystemObject");
var f=fso.CreateTextFile(cDialog.filename,true);
f.write(xx.value);
f.Close();
}
catch(e){}
}
function print()
{
try{
cDialog.CancelError=true;
cDialog.ShowPrinter();
}catch(e){}
}
</script>
</body>