开发者

Run protocol handler without opening windows in Javascript

开发者 https://www.devze.com 2023-02-16 16:55 出处:网络
I have a javascript that opens FILE with TextMate with txmt protocol. It works fine, but the problem is that I have a blank Safari window when this script is run.

I have a javascript that opens FILE with TextMate with txmt protocol. It works fine, but the problem is that I have a blank Safari window when this script is run.

document.onkeydown=function(e){
    if(e.which == 17) isCtrl=true;
    if(e.which == 69 && isC开发者_StackOverflowtrl == true) {
        mywindow = window.open("txmt://open/?url=file://FILE","myWindow");
        return false;
    }
}

How can I not open the blank window?


Try window.location = "your link"


You could try using XHR. Might work.


"Make your link, then simulate a click on it." was my first thought on how to do this. I've now tried it and it doesn't work, so I edited the answer to reply with this comment. It works fine for http links but not for anything else. I'm leaving this here because I would be interested if anyone knows why it doesn't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消