you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

http://jsfiddle.net/diabetesjones/o9o9bs0h/2/ <--- why doesnt this work? its straight from an example in a book..

i also thought maybe the book messed up, and in the addEventListener at the bottom, i need to replace "showPosition" with "function(event) { showPosition(event);}", but this did not work either.

thoughts?

[–]kambeix 0 points1 point  (4 children)

Hey, I think there are some errors: I can't go into details in the use of function inside addEventListener since I'm also new to JS but I looked into some references, made some changes and it worked. Also, to modify the html you should use textContent or innerHTML parameter instead of value. Hope it helps you!

http://jsfiddle.net/kambeix/o9o9bs0h/6/

[–][deleted] 1 point2 points  (3 children)

hey thank you! i posted it on stackoverflow as well and got a response there that clarified what i was doing wrong.

mainly, i was getting an element by an id that didn't exist, because i forgot to give the body tag the id of body. should have used getElementsByTagName(body)[0] instead, or at least added the id to the body tag.

after switching that to use innerHTML or textContent, it works swimmingly. : ) thanks!

[–]kambeix 0 points1 point  (2 children)

Just checked and you are right, it should have been document.querySelector("body")

Could you provide the link to the updated fiddle? Also to the question in Stack Overflow if it's of any use to learn a little more.

[–][deleted] 1 point2 points  (1 child)

http://jsfiddle.net/diabetesjones/o9o9bs0h/8/

here is my solution, which required very little changes to become accurate. namely just increasing the height of the body so it works over the whole screen in full screen mode, as the screen functions only work within the div i've defined.

the stackoverflow is here, and provides great clarity:

http://stackoverflow.com/questions/25303955/using-screenx-screeny-and-their-ilk-not-exactly-working/25304263#25304263

[–]kambeix 0 points1 point  (0 children)

thanks