Disable maximum popup button

Asked

Viewed 726 times

0

Someone tell me how to disable the maximize button in this popup window code?

<a onclick="window.open('http://endereco', 'aio_radio_player', 'width=720, height=355');
  • 1

    I believe that disabling the maximize button of someone else’s browser that opens with window.open is not possible, at least in conventional browsers.

  • Yes, same domain.

  • Did you solve it? If so, mark an answer with so as not to leave the question open. Or let us know if you still have problems so we can find the solution.

2 answers

2

Use the option resizable=no:

window.open('http://endereco', 'aio_radio_player',
   'width=720,height=355,location=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no');

I added a few more parameters for you to experience the effect of each one. I recommend that you individually test each option to see what applies to your case.

Note that the effectiveness of each depends on the implementation of the browser. For example, in my Firefox I deactivated support for several of the window options because I found some very inconvenient (how to prevent me from docking the popup in the main window).

See the MDN documentation to learn more about window.open:

https://developer.mozilla.org/en-US/docs/Web/API/Window/open

Description of some properties, removed from the link above:

Descrição da MDN

0

There is no way to disable the maximize button as the browser does not allow such control via code (except IE, which allows, at least in tested version 11).

But you can via Javascript create an event onresize to the window that will prevent you from resizing it (including preventing it from maximizing it). Simply store the initial dimensions in variables and when you try to resize, the script will return the window to its original size with the method resizeTo().

Note: the code will only work if the page to be opened in the window is of the same domain.

HTML of the link:

<a onclick="abre('t8_1.php'); event.preventDefault()" href="#" class="lista">Abrir janela</a>

Put in the onclick the function that will open the window by passing as parameter the URL of the page to be loaded. The event.preventDefault() will undo the click action on the link.

Function:

<script>
function abre(u){
   var popup = window.open(u,'aio_radio_player','width=720,height=355,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');

   popup.addEventListener("DOMContentLoaded", function(){
      var pu_width = popup.outerWidth; 
      var pu_height = popup.outerHeight;
      popup.onresize = function(){
         popup.resizeTo(pu_width, pu_height);
         popup.focus();
      }
   });
}
</script>

Functional example on this link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.