0

以下の Javascript 関数を使用してメモ帳でテキスト ファイルを開くことができません。支援したい場合は、この自明なスクリプトを実行してください。ありがとう。

  <script type="text/javascript">

  function RunURL(URL,Name) {
  window.open (URL,Name,
  "Width=1010,\
  Height=800,\
  Top=0,\
  Left=0,\
  Channelmode=0,\
  Titlebar=0,\
  Menubar=0,\
  Toolbar=0,\
  Directories=0,\
  Location=0,\
  Status=0,\
  Scrollbars=1,\
  Resizable=1,\
  Fullscreen=0");
  }

  </script>

残念ながら、コードをまとめて投稿することはできません...

  <html><form>

  <h2>Trying to open a text file in notepad for an Intranet app...</h2><br>

  First the easy one...<br>

  <input Type="button"; Value="Open Notepad"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe')";><br>

  <br>Now to open a text file so let's start with some common sense for the parameters as displayed in the buttons...<br>

  <input Type="button"; Value="?=C:\Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?=C:\Test.txt')";><br>
  <input Type="button"; Value="?=file:///C:/Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?=file:///C:/Test.txt')";><br>
  <input Type="button"; Value="?C:\Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?C:\Test.txt')";><br>

  <br>Desperation takes over!<br>

  <input Type="button"; Value="?open=file:///C:/Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?open=file:///C:/Test.txt')";><br>
  <input Type="button"; Value="?open=C:\Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?open=C:\Test.txt')";><br>
  <input Type="button"; Value="?open=C:/Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?open=C:/Test.txt')";><br>
  <input Type="button"; Value="?C:/Test.txt"; OnClick="RunURL('file:///C:/Windows/system32/notepad.exe?C:/Test.txt')";><br>

  <br>Could the file association alone trigger notepad to open it?<br>

  <input Type="button"; Value="file:///C:/Test.txt"; OnClick="RunURL('file:///C:/Test.txt')";><br>
  <input Type="button"; Value="C:/Test.txt"; OnClick="RunURL('C:/Test.txt')";><br>

  <br>Nope!<br>
  </form></html>

多分私はハンバーガーをひっくり返すことに戻る必要があります... :(

4

2 に答える 2

4

このようなローカル ファイルを開くために JavaScript を使用することはできません。これは、世界中の Web サイトがコンピュータ上で必要なプログラムを実行できないようにするセキュリティ メカニズムです。

ブラウザが実行を許可されている場合C:/Windows/system32/notepad.exe、何が呼び出しを停止しformat c:ますか?

于 2012-10-28T16:33:31.580 に答える
0

次のようにメモ帳でドキュメントを開くことができます。

RunURL('C:/Windows/system32/notepad.exe C:\Test.txt')

注:\最初の"notepad.exe"引数には、Windows スタイルのディレクトリ セパレータ — — を使用する必要があります。


編集:オデッドが言ったように:

ブラウザが C:/Windows/system32/notepad.exe の実行を許可されている場合、フォーマット c: の呼び出しを止めるにはどうすればよいでしょうか?

notepadのローカル コピーの「ダウンロード」を取得しますが、実行は取得しません。


編集2:これも見てください:

クライアント側でプログラムまたはバッチ ファイルを実行するにはどうすればよいですか?

于 2012-10-28T16:39:28.463 に答える