I'm a noob. I have a code to simulate a terminal. This is it: https://codepen.io/isdampe/pen/YpgOYr.
Command:
var coreCmds = {
"clear": clear
};
Answer (clear the screen):
function clear(argv, argc) {
termBuffer = "";
return "";
}
As mentioned in the title, how to add a command to launch a new tab in the browser (to google.com for example, or anywhere else)?
Thank you.
CodePudding user response:
window.open();
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
Here's an example:
window.open("https://www.google.com");
Structure:
window.open(URL, name, specs, replace)
Since you want to open a new tab in browser, you should put _blank
in name. However, this is the default.
What would your code look like?
This is a rough outline, replace variable names and arguments as you like
var var_name = {
"new window": new_window
};
function new_window(arguments) {
termBuffer = "";
return window.open(arguments);
}
I hope this helps :D
CodePudding user response:
Use the window.open
method with an input URL.
window.open('https://google.com')
This would open a tab to https://google.com
.