2

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 && isCtrl == true) {
        mywindow = window.open("txmt://open/?url=file://FILE","myWindow");
        return false;
    }
}

How can I not open the blank window?

prosseek
  • 182,215
  • 215
  • 566
  • 871

3 Answers3

4

Try window.location = "your link"

river
  • 1,508
  • 1
  • 12
  • 17
  • 1
    Littlebit tricky solution. When the protocol is unknown, an empty window will be opened and you leaving the current page. If javascript is enabled, create a hidden iframe that opens that url. – Codebeat Nov 29 '12 at 17:19
  • 1
    @Erwinus - Agreed, plus changing location may break certain things (long-polling is one example I came across). A good example of how to implement the iFrame solution can be found in http://stackoverflow.com/a/635750/3412775 – Tomty Dec 24 '14 at 13:43
0

You could try using XHR. Might work.

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
0

"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.

river
  • 1,508
  • 1
  • 12
  • 17