0

Edit: The basic question is the code below opens a popup window when the parent screen isn’t maximised. When the parent screen is maximised only a new tab is opened. I would like it to behave like a popup window only. Thanks. I’m running the code against Safari and Google Chrome.

An extract of the code is shown below (the part I am having the issue with):

   <form target="popUp" name="RngFrm" action="MapPHPCode3.php" method="post" onsubmit="popup(this);">

    <input name="lat" placeholder="Latitude" value="Latitude"></input>
    <input name="lng" placeholder="Longitude" value="Longitude"></input>
    <input name="rad2" placeholder="Radius" value="Radius"></input>
   <input type="submit">
   </form>

    <script>
    function popup(form) {
    window.open('', 'formpopup','menubar=yes,scrollbars=yes,resizable=yes,width=40,height=50');
    form.target = 'formpopup'; 
    };
      </script>
CGarden
  • 169
  • 17
  • 1
    There is no PHP in here, you are not closing the `popup` function – Spoody Mar 30 '18 at 18:34
  • I would use a
    with jquery and ajax to accomplish this. It won't work on a form submit with PHP alone.
    – briskovich Mar 30 '18 at 18:37
  • @MehdiBounya - Sorry I didn't copy that part in. I am closing it. – CGarden Mar 30 '18 at 18:50
  • @briskovich - Ok. It is all working though i.e. the php is pulling the data from MySQL and it is loading into a window which is what I want. I just want the window to be a popup. Or am I missing something here. I haven't used ajax/jquery yet. – CGarden Mar 30 '18 at 18:53
  • Can anyone help with this please. I feel like I’m nearly there... thank you – CGarden Mar 31 '18 at 07:45
  • Does anybody have anything to add? My question really is: Why does my code only create a popup window when the parent window is not maximised? When the parent window is not maximised the pop window is created. – CGarden Apr 02 '18 at 21:18
  • Probably simply the popup blocker at work. It might judge the situation differently, based on what “state” your parent window is in. My suggestion would be to let go of the idea that in this day and age you could still specify what dimensions a popup should have, or that it should even _be_ one ... because modern browsers allow to configure that. (Mine is set to _never_ open popups, but always new tabs at most.) – CBroe Apr 03 '18 at 08:12
  • you pass an empty string to `window.open` - how does it know to open a .php file? – treyBake Apr 03 '18 at 08:16
  • I think you need to determine parent window size. Please check [this](https://stackoverflow.com/questions/3437786/get-the-size-of-the-screen-current-web-page-and-browser-window). – Jaydeep Mor Apr 03 '18 at 08:26
  • Thank you. But once I have the parent window dimensions what would I do with it to fix my issue? – CGarden Apr 03 '18 at 12:39

1 Answers1

0

Please use another file for opening popups like this:

 window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"); 
Md Nazrul Islam
  • 363
  • 4
  • 13