Ahmad Sharif
Ahmad Sharif

Reputation: 4435

How to detect user CLICK on the pop up box "Exit full screen (F11)" with javascript?

When the screen is full screen mode. User may go the normal mode with pressing F11 or Click on the pop up box to go normal mode. How do i detect user click on the pop up box only not any kind of keypress "Exit full screen (F11)" with javascriptenter image description here

Remember I need click event listener not keypress event listener

Upvotes: 0

Views: 673

Answers (3)

Ahmad Sharif
Ahmad Sharif

Reputation: 4435

This is quit impossible. Browser stop all event listener from this popup. So that javascript could not listen any event from the popup.

Whatever I have fix my problem in other way. As my goal is to detect weather the screen is full or not. This may help to others

$(window).resize(function(){
  if (screenX !== 0 && screenY !== 0) {
     // Do your stuff here
  }

});

Upvotes: 0

Listening for a size change or the fullscreened element might give you a clue on the user exitting the fullscreen mode.

If you require the click event specifically, because you need to have it in the stack for things like opening a new window or other things that require user interaction, you are out of luck, though.

Upvotes: 0

Abhinay
Abhinay

Reputation: 348

Popup box might be a div or some html element which might be having an id. So, consider registering an click event listener based on id. Whenever user clicks on that element, the registered function gets fired. Refer below sample script. In the below script "abc" is the id of a div and I have registered a click event called "myFunction", whenever user clicks on the div then myFunction will be called.

document.getElementById("abc").addEventListener("click", myFunction);

function myFunction() {
//Do Something
}

Upvotes: 0

Related Questions