How to close a window after the firewall closes inside php

I need to close the window after the warning, I used the codes asked in the Stack question But my notification field is inside the php code, I get the warning field, but as soon as I close it, the window does not close, I'm new to php. The codes below, please help me guys.

<?php $serial_get = trim(str_replace("(","",str_replace(")","",GetVolumeLabel("d")))); if ($serial_get == '1233-2AZ2'){ } else{ echo '<script language="javascript"> window.alert("This is not a Licensed Software. Please contact IT Solutions."); window.close() </script>'; }?> 
+5
source share
2 answers

You need window.open(...) to be able to window.close() . You are using window.alert() .

See Best Practice at https://developer.mozilla.org/en-US/docs/Web/API/Window.open

+1
source

Some browsers will not honor the command unless it is user initiated. But ... Here is a workaround that might work for you. try instead of close :

 open(location, '_self').close(); 

Or maybe trick the browser into thinking that it was user initiated. It may or may not work; not tested. I'm just throwing spaghetti against the wall ...

 var btn = document.createElement('button'); document.body.appendChild(btn); btn.addEventListener('click', function() { open(location, '_self').close(); }, false); btn.dispatchEvent(new Event('click')); 
0
source

Source: https://habr.com/ru/post/1209305/


All Articles