Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript popup window, works on one page, but not on another
    primarykey
    data
    text
    <p>I have a javascript popup window on several pages of my website. I used the a centered popup window I found on <a href="https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen">Center a popup window on screen?</a></p> <pre><code>function popupwindow(url, title, w, h) { var left = (screen.width/2)-(w/2); var top = (screen.height/2)-(h/2); return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); } </code></pre> <p>This popup window works on some pages, but not on other pages...</p> <p>I made 2 pages to show, on the first page the popup works<br> <a href="http://www.weddingpages.nl/test1.php" rel="nofollow noreferrer">http://www.weddingpages.nl/test1.php</a><br> and on the second page the popup doesn't work:<br> <a href="http://www.weddingpages.nl/test2.php" rel="nofollow noreferrer">http://www.weddingpages.nl/test2.php</a></p> <p>The source of the pages is exactly the same (copy, paste), only on the second page I deleted the form.</p> <p>So if I understand correctly, this popup JavaScript only works when there is also a form on the page?</p> <p>Here is the code of the page where the popup works:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;test1&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt; &lt;script type="text/javascript"&gt; function popupwindow(url, title, w, h) { var left = (screen.width/2)-(w/2); var top = (screen.height/2)-(h/2); return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form class="form-horizontal" action="" method="post"&gt; &lt;div class="control-group"&gt; &lt;label class="control-label" for="title"&gt;Naam website / bedrijf:&lt;/label&gt; &lt;div class="controls"&gt; &lt;input type="text" class="span3" id="title" name="title" placeholder="Naam website / bedrijf"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;div class="controls"&gt; &lt;button type="submit" name="submit" class="btn"&gt;Gegevens opslaan&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;a href="javascript:popupwindow('http://www.google.com/', title, 1400, 700)"&gt;centered Pop up window&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So if you delete the form, the javascript stops working.</p> <p>Is there anybody who can tell me why ? I am trying to find the solution already for almost 2 days :-(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload