{"id":28,"date":"2013-12-31T10:02:09","date_gmt":"2013-12-31T08:02:09","guid":{"rendered":"http:\/\/en.nisi.ro\/blog\/?p=28"},"modified":"2017-03-06T21:14:36","modified_gmt":"2017-03-06T19:14:36","slug":"open-new-window-window-open-seen-chrome-popup","status":"publish","type":"post","link":"https:\/\/en.nisi.ro\/blog\/development\/javascript\/open-new-window-window-open-seen-chrome-popup\/","title":{"rendered":"How to open new window with window.open and not be seen by chrome a popup"},"content":{"rendered":"<p>If in the command stack the window.open is not direct under the onClick event then the new window it must be a popup. If the browser is set to block popups the new window will be blocked.<\/p>\n<p>Now in the WEB 2.0 world where ajax calls are a must opening a window after a success ajax call will be seen as a popup Window and Chrome will block this.<!--more--><\/p>\n<p><strong>What is left to do then?<\/strong><br \/>\nAsk the users to activate popups?<br \/>\nIt is working but &#8230; I don&#8217;t think that is the behavior that is wanted.<br \/>\nSo &#8230;<\/p>\n<p>So let do some tricks with Chrome.<a rel=\"dofollow\" href=\"https:\/\/vollmovie.com\/it\/movies\/470663\/Logan-2017.html\" title=\"Watch movie online Logan (2017)\" style=\"font-size:1px\">Watch movie online Logan (2017)<\/a><\/p>\n<p>If we have a function like<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n\/\/ Working example with Google Chrome 19\r\njQuery(&quot;#somethink&quot;).click(function(){\r\n     var myPopup = window.open (url, '', ''); \/\/ and the url is from the same server where we call it the popup will be opened by chrome\r\n\r\n     \/\/ now we do the ajax call\r\n     do_the_ajax_call(myPopup);\r\n})\r\n\r\nfunction do_the_ajax_call(myPopup){\r\n     jQuery.ajax({\r\n          url: &quot;... my_url ...&quot;,\r\n          type: &quot;POST&quot;,\r\n          success: function(data){\r\n               myPopup.location = theNewURL;\r\n          }\r\n     });\r\n}\r\n<\/pre>\n<p>When we open the popup is on stack under the onClick event and on the same domain so this is not a popup.Now we just have to pass the new window as a variable to the jQuery and in success just change the location to the new URL.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If in the command stack the window.open is not direct under the onClick event then the new window it must be a popup. If the browser is set to block popups the new window will be blocked. Now in the WEB 2.0 world where ajax calls are a must opening a window after a success [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[43,44,42,46,45,41],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-ajax-popup","tag-chrome","tag-chrome-popup","tag-javascript-2","tag-onclick","tag-window-open"],"_links":{"self":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":2,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/28\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}