5 ms·
As parent said, you just need to store a handle to the window when you open it, and then you can use .close() https://developer.mozilla.org/en-US/docs/Web/API/
by jakub_g 10y ago
As parent said, you just need to store a handle to the window when you open it, and then you can use .close()
https://developer.mozilla.org/en-US/docs/Web/API/Window/close#Examples https://developer.mozilla.org/en-US/docs/Web/API/Window/clos...
- dang 10y agoWhen opening a tab are you allowed to say where you want it in the tab order? or to change its position in the tab order later? Thanks everyone for all the help!
- tempestn 10y agoUnfortunately I don't think so. In fact you can't even specify that you want it to be a tab, as opposed to a new window, but the default in all major browsers is a tab these days. I haven't tested, but you might be able to kind of fake it by having the tab immediately before the one you want to open do the opening. That wouldn't work for tabs that have opened external sites (the stories themselves), but you could at least send a message to one of the other HN tabs telling it to open your new tab, which should give you some control.
- dang 10y agoI see. The Chrome.tabs library that I use does allow this. Your clever workaround might be enough though. While I'm at it, is there a way to give a regular web app the kind of permissions that a Chrome extension manifest can give? It isn't just tab mechanics I need, but clipboard access and cross-domain privileges. Obviously this would still require client consent (and might still be Chrome-only) but it would be easier than an extension with all its deployment headaches.
- jakub_g 10y agoThere's a clipboard API [1] in newest browsers but browser support varies. Regarding cross-domain, what do you want to do exactly? In general there's no built-in support at least in Firefox to override default same-origin policy, but there are Chrome/Firefox extensions that for instance inject CORS headers to each response. Edit: In Chrome, it seems you can disable same-origin policy with command line flag [2] [1] http://caniuse.com/#feat=clipboard http://caniuse.com/#feat=clipboard [2] http://stackoverflow.com/a/3177718/245966 http://stackoverflow.com/a/3177718/245966
- dang 10y agoI might be forgetting something but I think the main use of cross-domain privileges is so that my keyboard shortcuts still work on story pages. That way, if I open (say) a NYT article that is currently highlighted on the front page, I can jump back to the front page when I'm done looking at it.