I'm using this extension to get a blank page each time I open a new tab, unfortunately the address bar is not focused after the new tab is open.
I changed the new page contents to dispatch the keystroke 9 to simulate the tab key. which causes the browser to focus on the address bar but it didn't work.
<title></title>
<script>
function init() {
var k = 9;
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
Object.defineProperty(oEvent, 'which', {
get : function() {
return this.keyCodeVal;
}
});
if (oEvent.initKeyboardEvent) {
oEvent.initKeyboardEvent("keydown", true, true, document.defaultView, false, false, false, false, k, k);
} else {
oEvent.initKeyEvent("keydown", true, true, document.defaultView, false, false, false, false, k, 0);
}
oEvent.keyCodeVal = k;
if (oEvent.keyCode !== k) {
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
}
document.dispatchEvent(oEvent);
}
</script>
<body onload="init()">
</body>
Is there some alternative to do that?