Skip to content

Instantly share code, notes, and snippets.

@scheib
Created November 28, 2012 22:49
Show Gist options
  • Save scheib/4165303 to your computer and use it in GitHub Desktop.
Save scheib/4165303 to your computer and use it in GitHub Desktop.
chrome-app-onload-focus
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html');
});
{
"name": "onload focus test",
"description": "Test that when a window is created it can have focus.",
"version": "1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"permissions": [ ]
}
<html>
<body>
<p>When this app is opened the text area below should be focused and able to
receive text. Note that this works when loading this page window.html in
a browser.</p>
<textarea>Initial text.</textarea>
<script src="window.js"></script>
</body>
</html>
window.onload = function () {
document.querySelector("textarea").value = "Type here.";
document.querySelector("textarea").focus();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment