我使用这个 vbscript 代码将 IE9 中显示的页面保存为 mht 文件。要运行它,请将其放在收藏夹栏中,然后单击它。问题是它将保存页面,但文件名将以 ## 结尾,例如homepage##.mht
。有谁看到如何删除文件名上的##?我看到它在逻辑中用于执行任务,但这很烦人,哈哈。
谢谢。
Set ies=CreateObject("Shell.Application").Windows()
For Each ie In ies
If ie.ReadyState=4 Then If TypeName(ie.Document)="HTMLDocument" Then If ie.Document.hasFocus() Then Exit For
Next
If IsEmpty(ie) Then
For Each ie In ies
If ie.ReadyState<>4 Then
ElseIf TypeName(ie.Document)="HTMLDocument" Then
ie.Document.focus
If ie.Document.hasFocus() Then Exit For
End If
Next
End If
If IsEmpty(ie) Then
MsgBox "Not Found"
WScript.Quit
End If
href=ie.locationURL
Set a=ie.Document.createElement("a")
a.href=href
a.hash="##"
ie.Document.parentWindow.setTimeout "location.replace """ & a.href & """",0,"vbscript"
Do While ie.Document.parentWindow.location.hash<>"##"
WScript.Sleep 100
Loop
ie.ExecWB 4,1
ie.Document.parentWindow.location.replace href