1

Hi I'm trying to create chrome app that will track the browser window position, (Sorry for the lame question, it's just so hard to find information with the words 'chrome' and 'app' on SE)

P.S I want to create chat app that will dock to the browser window instead of the screen

Adi Darachi
  • 2,137
  • 1
  • 16
  • 29

1 Answers1

0

Unless I'm misunderstood, Chrome apps are written in Javascript.

Piggybacking off the answer from here:

X - window.screenX
Y - window.screenY

Keep in mind, implementations vary (non-issue for a chrome app). Beware of multi-monitor setups...

Community
  • 1
  • 1
alecdwm
  • 915
  • 11
  • 13
  • I want the chrome App (not extension), To be relative to the chrome-browser window. – Adi Darachi Jan 24 '16 at 15:18
  • 1
    Ah. This will be difficult when chrome app windows [are not associated with any Chrome browser window](https://developer.chrome.com/apps/app_window) – alecdwm Jan 24 '16 at 15:25
  • Any way to simulate the behavior i am seeking in other ways? (not within other website/tab) – Adi Darachi Jan 24 '16 at 15:31
  • 1
    Looking over the documentation it seems pretty unlikely. If you absolutely must have this functionality, perhaps you could script a separate chrome extension which spits out a chosen browser window's position and size via a http call on localhost? Then you could poll it from your chrome app and update accordingly. A very inelegant solution though... and I'm not entirely sure whether it's possible either. – alecdwm Jan 24 '16 at 15:51
  • You answer are very helpful. What about to create extension with website frame that is not iframe on the page (wont reload if the tab is being reloaded), is that possible? – Adi Darachi Jan 24 '16 at 16:22
  • Post your answer, I'll accept it (in few hours) since it's the closest thing to an answer – Adi Darachi Jan 24 '16 at 17:22
  • I don't completely understand what you are describing, but I'll give it a go: Do you mean to write an extension which will overlay your chat program over any website the browser visits? Not only this, but to remain on the page between tab redirects + reloads? – alecdwm Jan 25 '16 at 12:19
  • exactly, I can't describe it better. ( But on specific tab, will be the best. ) – Adi Darachi Jan 25 '16 at 12:20
  • The first bit (a chat program overlay for any website the browser visits) should indeed be possible. Just write your program to wait for the DOM to load, then inject your chat program's markup into the page. For it to remain on the page when the browser reloads though, will very likely not be possible. – alecdwm Jan 25 '16 at 12:23
  • You could however store the chat program's state in whatever persistent storage Chrome makes available to extensions, then just re-inject the chat program when the page is reloaded. – alecdwm Jan 25 '16 at 12:24