以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]往静态网页插入html代码,禁用右键菜单 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=117824) |
-- 作者:jframe -- 发布时间:2018/4/19 15:35:00 -- [求助]往静态网页插入html代码,禁用右键菜单 为了让显示的网页不能右键, 服务器上已存在html静态网页,是完整的网页,现在要在显示时,在最后加入一个js文件, Dim fl As String = "D:\\web\\" & e.path If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".jpeg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar" e.WriteFile(fl) Return \'这里必须返回 End Select End If 能不能在 e.WriteFile(fl) 代码后面, 用 e.WriteString("<script type=\'text/javascript\' src=\'nocontextmenu.js\'></script>") 或者wb.inserthtml("<script type=\'text/javascript\' src=\'nocontextmenu.js\'></script>") 来在网页最后加入一个js文件 或者又其他更好更方便的,禁用网页右键的办法??? [此贴子已经被作者于2018/4/19 16:42:26编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/4/19 15:43:00 -- 参考 http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=116381&skin=0
|
-- 作者:jframe -- 发布时间:2018/4/19 16:41:00 -- 谢谢甜总 Dim fl As String = "D:\\web\\" & e.path If filesys.FileExists(fl) Dim idx As Integer = fl.LastIndexOf(".") Dim ext As String = fl.SubString(idx) Select Case ext Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".zip",".rar",".jpeg" e.WriteFile(fl) Return \'这里必须返回 Case ".html",".htm" Dim s As String = FileSys.ReadAllText(fl,Encoding.Default) s = s.Replace("</body>","<script Type=\'text/javascript\' src=\'nocontextmenu.js\'></script></body>") \'网页禁止鼠标右键 e.WriteString(s) Return \'这里必须返回 End Select End If 如果以上代码出来的html有乱码, 则去掉Encoding.Default 改为 Dim s As String = FileSys.ReadAllText(fl)
[此贴子已经被作者于2018/4/20 10:58:36编辑过]
|