0

When you type javascript:window.open('http://stackoverflow.com') in chrome's navigation bar, it opens new tab. I want same, but when running chrome from cmd:

var process = Process.Start("chrome.exe",
    "javascript:window.open('http://stackoverflow.com')");

I'm doing this because I want to close that window later from inside it with window.close(). If I open website directly, error is thrown:

Scripts may close only the windows that were opened by it.
karaxuna
  • 26,752
  • 13
  • 82
  • 117

1 Answers1

0

If you just want chrome to open a new tab to a page, why not try:

var process = Process.Start("chrome.exe", "http://stackoverflow.com");

If you just want to close the window later with JS, what about:

    window.open(location, '_self', '');
    window.close();

Note, you cannot automatically add the javascript prefix to a chrome URL, even with copy and paste - this is a security feature.

see - Javascript stripped from URL bar?

Edwin Jones
  • 309
  • 2
  • 4