2

我在浏览器中遇到了发送文件链接的问题:

file:/// 而不是 file://,我想创建一个 zimlet,它是检查邮件中的链接,如果它是文件链接,则将 file:/// 更改为 file://,然后单击开始。

或者如果是文件链接,则启动外部程序。我创建了链接阅读器程序,但我不知道如何启动它或实现到 zimlet。你有什么主意吗?提前感谢您的帮助。我在 .net 中进行链接校正的示例,但它在 java ajax 中的样子:

 foreach (string b in args)
            {


                //  Console.WriteLine(b);
               if (b.Contains("file:F"))
                {
                     string d = b.Replace(@"file:F", @"F");
                     System.Diagnostics.Process.Start(d);
                }
          else if (b.Contains("file:///F:"))
               {
                   string d = b.Replace(@"file:///F:", @"F:");
                   System.Diagnostics.Process.Start(d);
               }

}

在这里,字符串被读取并检查并替换为良好的起始字符。我认为它也必须在java中工作,但我在java中不好。

请帮忙!

我尝试使用转换器:但它不起作用:

try
    {
        for (String b : args)
        {


            //  Console.WriteLine(b);
           if (b.contains("file:F"))
           {
                 String d = b.replace("file:F", "F");
                 System.Diagnostics.Process.Start(d);
           }

           else if (b.contains("file:///F:"))
           {
               String d = b.replace("file:///F:", "F:");
               System.Diagnostics.Process.Start(d);
           }

           else
           {
               System.out.println("File Not Contain Valid File Link!");
               System.out.println("Or File Missing!");
               Console.ReadKey();
           }
            // Console.WriteLine(d);
            //  Console.ReadKey();
          //  System.Diagnostics.Process.Start(d);
        }
    }
    catch (RuntimeException e)
    {


        System.out.println("File Not Contain Valid File Link!");
        System.out.println("Or File Missing!");
        Console.ReadKey();


    }

我有一个新想法!如何在新标签中自动运行链接?就像我点击一个链接而不是自动打开新标签并将网址复制到那里并运行一样。我认为它必须是一个右键菜单。它应该工作。

更新:现在我使用一个例子:对于右键菜单现在它正在点击弹出消息:

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The onClicked callback function.
function onClickHandler(info, tab) {
  if (info.menuItemId == "radio1" || info.menuItemId == "radio2") {
    console.log("radio item " + info.menuItemId +
                " was clicked (previous checked state was "  +
                info.wasChecked + ")");
  } else if (info.menuItemId == "checkbox1" || info.menuItemId == "checkbox2") {
    console.log(JSON.stringify(info));
    console.log("checkbox item " + info.menuItemId +
                " was clicked, state is now: " + info.checked +
                " (previous state was " + info.wasChecked + ")");

  } else {
    console.log("item " + info.menuItemId + " was clicked");
    console.log("info: " + JSON.stringify(info));
    console.log("tab: " + JSON.stringify(tab));
  }

弹出消息在这里

alert("I am an alert box!");
};

chrome.contextMenus.onClicked.addListener(onClickHandler);

// Set up context menu tree at install time.
chrome.runtime.onInstalled.addListener(function() {
  // Create one test item for each context type.
  var contexts = ["page","selection","link","editable","image","video",
                  "audio"];
  for (var i = 0; i < contexts.length; i++) {
    var context = contexts[i];
    var title = "Test '" + context + "' menu item";
    var id = chrome.contextMenus.create({"title": title, "contexts":[context],
                                         "id": "context" + context});
    console.log("'" + context + "' item:" + id);
  }

  // Create a parent item and two children.
  chrome.contextMenus.create({"title": "Test parent item", "id": "parent"});
  chrome.contextMenus.create(
      {"title": "Child 1", "parentId": "parent", "id": "child1"});
  chrome.contextMenus.create(
      {"title": "Child 2", "parentId": "parent", "id": "child2"});
  console.log("parent child1 child2");

  // Create some radio items.
  chrome.contextMenus.create({"title": "Radio 1", "type": "radio",
                              "id": "radio1"});
  chrome.contextMenus.create({"title": "Radio 2", "type": "radio",
                              "id": "radio2"});
  console.log("radio1 radio2");

  // Create some checkbox items.
  chrome.contextMenus.create(
      {"title": "Checkbox1", "type": "checkbox", "id": "checkbox1"});
  chrome.contextMenus.create(
      {"title": "Checkbox2", "type": "checkbox", "id": "checkbox2"});
  console.log("checkbox1 checkbox2");

  // Intentionally create an invalid item, to show off error checking in the
  // create callback.
  console.log("About to try creating an invalid item - an error about " +
      "duplicate item child1 should show up");
  chrome.contextMenus.create({"title": "Oops", "id": "child1"}, function() {
    if (chrome.extension.lastError) {
      console.log("Got expected error: " + chrome.extension.lastError.message);
    }
  });
});

我创建了一个运行我的 exe 的 hta 文件:

<script type="text/javascript" language="javascript">
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "F:\\ABLAGE\\link_reader_ip.exe"; 
oShell.ShellExecute(commandtoRun,"","","open","1");
</script>

新问题: 1、点击hta文件如何启动:

function callShellApplication(){
var objShell = new ActiveXObject("WScript.shell");
objShell.Run('"d:\\test.hta"');
}

没有错误,但 test.hta 文件不会启动。

  1. 如果 hta 运行我的文件,它会打开一个额外的窗口,但我不会。

请有人帮助我。

4

0 回答 0