首先抱歉标题不好,如果有人可以更好地命名这个问题,请做。
我有这个 HTML 文件:
<html>
<form action='' method='post'>
<input id='inbox' type='file' />
<input id='outbox' type='button' onclick='alert(inbox.value);'
value='submit' />
</form>
</html>
当我用 IE 打开它,然后浏览文件并单击“提交”按钮时,我会收到所选文件的完整路径的警报。但是,如果我尝试使用 VBScript 编写相同的脚本:
Set IE = CreateObject("InternetExplorer.Application")
IE.Offline = True
IE.Navigate "about:blank"
Do
Loop While IE.Busy
html = "<html>" &_
" <form action='' method='post'>" &_
" <input id='inbox' type='file' />" &_
" <input id='outbox' type='button' onclick='alert(inbox.value);'" &_
" value='submit' />" &_
" </form>" &_
"</html>"
IE.Document.write html
IE.Width = 0
IE.Height = 0
IE.Document.All("inbox").Click
IE.Document.All("outbox").Click
我收到了臭名昭著的c:\fakepath\file.ext
消息。
有谁知道为什么会这样甚至更好地克服它?