確認した環境はWindows7pro SP1 32bit、IE11.0.9600.18376
以下のようなウィンドウをプログラムから任意のタイミングで開けます。
起動するとファイルの選択画面が表示されます。
選択できるのは1つのファイルだけです。フォルダとか、複数のファイルは選択できません。
選択するとdocument.body.innerTextにそのファイルのPathが入力されます。

以前はセキュリティの都合で「画面上に表示されている「参照」ボタンをユーザーがクリックしなければ、ファイル選択ウィンドウは開かない」ということになっていたような気がするのですが。。
ソース
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title>ファイルを開く</title> | |
<body> | |
</body> | |
<script> | |
d=document.createElement('div') | |
d.innerHTML = '<input type="file" style="display:none;">' | |
inp = d.firstChild | |
inp.click() | |
document.body.innerText = inp.value | |
</script> | |
</html> |
0 件のコメント:
コメントを投稿