论坛: 网站建设 标题: 网页“记事本”程序 复制本贴地址    
作者: tabris17 [tabris17]    论坛用户   登录
在nsfocus上看到这么一个东东,是E文版的,但是再我系统上显示有错误,看不到弹出菜单,于是决定自己做了一个,现在做了一半。

把下列代码保存为notepad.hta文件:


<HTML>
<HEAD>
<TITLE>记事本</TITLE>
<HTA:APPLICATION ID="oHTA" APPLICATIONNAME="myApp" BORDER="thick" BORDERSTYLE="normal" CAPTION="yes"
ICON="notepad.exe" MAXIMIZEBUTTON="yes" MINIMIZEBUTTON="yes" SHOWINTASKBAR="yes" SINGLEINSTANCE="no"
SYSMENU="yes" VERSION="1.0" WINDOWSTATE="normal" NAVIGABLE="yes" SCROLL="no" INNERBORDER="no">
<style>
.menu{font-size:9pt;padding-top:4px;padding-right:4px;padding-bottom:2px;padding-left:4px;}
textarea{height:expression(document.body.clientHeight-menu.clientHeight-1);width:100%;}
.menuhelp{position:absolute;top:21px;border-width:1;border-style:solid;visibility:hidden;
border-top-color:Menu;border-left-color:Menu;border-bottom-color:black;border-right-color:black}
.popmenu{padding-top:4px;padding-right:20px;padding-bottom:4px;padding-left:20px;
border-width:1;border-style:solid;border-bottom-color:gray;border-right-color:gray}
</style>
<script>
function nosel()
{
window.event.returnValue=false;
}
function showmenu(menuid)
{
switch(menuid)
{
case 1:popopen.style.visibility="visible";break;
case 2:popedit.style.visibility="visible";break;
case 3:break;
case 4:pophelp.style.visibility="visible";break;
}
}
function hidemenu()
{
pophelp.style.visibility="hidden";
popopen.style.visibility="hidden";
popedit.style.visibility="hidden";
}
function selall()
{
var rng = workshop.createTextRange();
rng.moveToElementText(workshop);
rng.scrollIntoView();
rng.select();
rng.collapse(false);scrollTo(0,0);
}
function copytext()
{
var rng = workshop.createTextRange();
rng.moveToElementText(workshop);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
scrollTo(0,0);
}
fso = new ActiveXObject("Scripting.FileSystemObject");
fn=null;
function opendialog()
{
fn=prompt("输入你要打开的文件路径:","notepad.hta");
if(fn!=null)
{
var file = fso.OpenTextFile(fn);
var filetext = file.ReadAll();
workshop.value=filetext;
}
}
function savefile()
{
if(fn!=null)
{
var file = fso.CreateTextFile(fn,true);
file.Write(workshop.value);
file.close();
}
}
function saveas()
{
var fntmp=prompt("输入你要保存的文件路径:",fn);
if(fntmp!=null)
{
fn=fntmp;
var file = fso.CreateTextFile(fn,true);
file.Write(workshop.value);
file.close();
}
}
</script>
</HEAD>
<BODY leftmargin=0 rightmargin=0 topmargin=0 id=form  bgcolor="Menu">
<table oncontextmenu="nosel()" onselectstart="nosel()" id=menu align=center bgcolor=Menu border=0 width=100% cellpadding=0 cellspacing=0 style="border-collapse: collapse">
<tr>
<td width=220>
<table class=menu width=220 border=0 cellpadding=0 cellspacing=0 style="border-collapse: collapse" onmouseover="this.style.cursor='default'">
<tr>
<td align=center id=file width=55 onclick="hidemenu();showmenu(1)">文件<font face="MS Gothic">(F)</font></td>
<td align=center id=edit width=55 onclick="hidemenu();showmenu(2)">编辑<font face="MS Gothic">(E)</font></td>
<td align=center id=option width=55 onclick="hidemenu();showmenu(3)">格式<font face="MS Gothic">(O)</font></td>
<td align=center id=option width=55 onclick="hidemenu();showmenu(4)">帮助<font face="MS Gothic">(H)</font></td>
</tr>
</table>
</td>
<td align=left onclick=hidemenu() style=color:Menu onmouseover=this.style.cursor='default'>Create by:tabris17</td>
</tr>
</table>




<div class=menuhelp id=pophelp style="left:165px;">
<table onselectstart="nosel()" onmouseover="this.style.cursor='default'" class=popmenu border=0 bgcolor=Menu cellpadding=0 cellspacing=1 style=border-collapse: collapse style="font-size:9pt">
<tr><td onclick="hidemenu();window.open('http://www.20cn.net/~tabris17');" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">帮助主题<font face="MS Gothic">(H)</font></td></tr>
<tr><td style="line-height:0;padding-left:1;padding-right:1;padding-bottom:0;padding-top:0;"><hr width=116></td></tr>
<tr><td onclick="hidemenu();alert('Copyleft:tabris17');" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">关于记事本<font face="MS Gothic">(A)</font></td></tr>
</table>
</div>

<div class=menuhelp id=popopen style="left:0px;">
<table onselectstart="nosel()" onmouseover="this.style.cursor='default'" class=popmenu border=0 bgcolor=Menu cellpadding=0 cellspacing=1 style=border-collapse: collapse style="font-size:9pt">
<tr><td onclick="hidemenu();opendialog();" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">打开<font face="MS Gothic">(O)</font></td></tr>
<tr><td onclick="hidemenu();savefile();" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">保存<font face="MS Gothic">(S)</font></td></tr>
<tr><td onclick="hidemenu();saveas();" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">另保为<font face="MS Gothic">(A)</font>...</td></tr>
<tr><td onclick="hidemenu();workshop.value='';fn=null;" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">关闭<font face="MS Gothic">(C)</font></td></tr>
<tr><td style="height:1px;padding-left:1;padding-right:1;padding-bottom:0;padding-top:0;"><hr width=100></td></tr>
<tr><td onclick="hidemenu();window.close();" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">退出<font face="MS Gothic">(X)</font></td></tr>
</table>
</div>

<div class=menuhelp id=popedit style="left:55px;">
<table onselectstart="nosel()" onmouseover="this.style.cursor='default'" class=popmenu border=0 bgcolor=Menu cellpadding=0 cellspacing=1 style=border-collapse: collapse style="font-size:9pt">
<tr><td onclick="hidemenu();selall()" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">全选<font face="MS Gothic">(A)</font></td></tr>
<tr><td onclick="hidemenu();copytext()" onmouseover="this.style.background='#0a246a';this.style.color='white'" onmouseout="this.style.background='Menu';this.style.color='black'">复制全部<font face="MS Gothic">(C)</font></td></tr>
</table>
</div>

<textarea style="font-family:Fixedsys;" id=workshop application=yes scrolling=yes width=100% onclick="hidemenu()"></textarea>

</BODY>
</HTML>

[此贴被 四不象(tabris17) 在 01月31日17时00分 编辑过]

地主 发表时间: 04-01-30 21:59

回复: newekin [newekin]      登录
做了那么长时间的网页  头一次见到html标签和js能做到这个效果  惭愧~~

B1层 发表时间: 04-01-30 23:12

回复: q70213526 [q70213526]   版主   登录
不错不错
可惜我不太会,

B2层 发表时间: 04-01-31 15:36

回复: tabris17 [tabris17]   论坛用户   登录
更新过了,基本功能都全了,可以打开、保存、编辑文本文件

B3层 发表时间: 04-01-31 17:02

回复: Idof [idof]   论坛用户   登录
不错
我也没想到HTML竟然有此功能

B4层 发表时间: 04-01-31 18:46

回复: poemail [poemail]   论坛用户   登录
保存成该文件名后是不是菜单栏乱码呀,(也不象繁体中文呀)并且里面都是空的呀,居然打开是用记事本呀!

B5层 发表时间: 04-01-31 22:13

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号