{"id":6350,"date":"2023-01-13T04:52:20","date_gmt":"2023-01-13T04:52:20","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=6350"},"modified":"2023-01-13T09:54:25","modified_gmt":"2023-01-13T09:54:25","slug":"open-a-popup-window-with-a-window-open-passing-parameters-as-post","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/","title":{"rendered":"Open a popup window with a window.open() passing parameters as \u2018post\u2019"},"content":{"rendered":"<p>Target is to open a third-party page but not using query parameters in the URL, instead using a post approach. And this is to be achieved through javascript without creating.<\/p>\n<p>This can be achieved by creating an Html page with the form submit with post method in the application which is and using action attribute with the post URL, but here the target is without creating the Html page, create on the fly Html content and submit a form from the client-side in the new window opened as a popup to the third party link at the server-side. This can be simply achieved using the following javascript code:<br \/>\n<code>var windowName = 'myWindow';<br \/>\nvar windowProperty = 'location=yes,height=700,width=800,scrollbars=1,status=yes,titlebar=no,top=100,left=300';<br \/>\nvar data= getData();<br \/>\n\/\/ let data variable is the required array of data values to be submitted<br \/>\nvar popupSubmitWindowForm = '&lt;form id=\"popupDocumentForm\" method=\"post\" action=\"' + url + '\" target=\"' + windowName+'\"&gt;'<br \/>\n+ '&lt;input type=\"hidden\" name=\"InputParam0\" value=\"' +data[0]+ '\"&gt;'<br \/>\n+ '&lt;input type=\"hidden\" name=\"InputParam1\" value=\"' +data[1]+ '\"&gt;'<br \/>\n+ '&lt;input type=\"hidden\" name=\"InputParam2\" value=\"' +data[2] + '\"&gt;'<br \/>\n+ '&lt;\/form&gt; '<br \/>\n+ '&lt;script&gt;'<br \/>\n+ 'var popupDocumentForm= document.getElementById(\"popupDocumentForm\");'<br \/>\n+ 'popupDocumentForm.submit();'<br \/>\n+ '&lt;\/script&gt;';<br \/>\n\/* detect if the window is already opened. This is required especially in cases when dealing with third-party links*\/<br \/>\nlet windowExists = false;<br \/>\nif (popupDocWindow &amp;&amp; popupDocWindow!=null) {<br \/>\nwindowExists = true;<br \/>\n}<br \/>\nif (windowExists == true) {<br \/>\npopupDocWindow.close();<br \/>\n}<br \/>\nelse {<br \/>\n\/\/ apply any required code<br \/>\n}<br \/>\npopupDocWindow = window.open('', windowName, windowProperty);<br \/>\npopupDocWindow.document.write(popupSubmitWindowForm);<\/code><\/p>\n<p>To achieve on-the-fly form submit, we can simply create a form Html with input elements containing required post data and script that triggers the form submit action. Now this dynamic Html and javascript content can be written to the newly opened popup window from the parent window using <a href=\"https:\/\/studysection.com\/blog\/javascript-2\/\">javascript<\/a>. This way we can open dynamic popup windows without actually creating Html pages with the \u2018post\u2019 method approach.<\/p>\n<p>When working third-party apps, generally we face blocking restriction\/domain restriction errors on the browser, so sometimes we need to detect if a window is already opened when reopening the window with new data. If you face such issues, then simply we need to first close the current window and then open the new window. Otherwise, if we want to open the windows simultaneously, then we can just create unique window names.<\/p>\n<p><small><em>StudySection provides a Windows 10 certification exam to help those with skills in Microsoft Windows 10 operating system. This exam is available for two different levels namely \u201cFoundation\u201d and \u201cAdvanced\u201d. This <a href=\"https:\/\/www.studysection.com\/windows-10-advanced\">Windows 10 Certification<\/a> can help you land in a good job position when attached to your resume.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Target is to open a third-party page but not using query parameters in the URL, instead using a post approach.<\/p>\n","protected":false},"author":1,"featured_media":6351,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[829,830],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Open a popup with a window.open passing parameter - SS Blog<\/title>\n<meta name=\"description\" content=\"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Open a popup with a window.open passing parameter - SS Blog\" \/>\n<meta property=\"og:description\" content=\"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-13T04:52:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-13T09:54:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/01\/parameters.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Open a popup window with a window.open() passing parameters as \u2018post\u2019\",\"datePublished\":\"2023-01-13T04:52:20+00:00\",\"dateModified\":\"2023-01-13T09:54:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\"},\"wordCount\":304,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"parameters\",\"window\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\",\"url\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\",\"name\":\"Open a popup with a window.open passing parameter - SS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2023-01-13T04:52:20+00:00\",\"dateModified\":\"2023-01-13T09:54:25+00:00\",\"description\":\"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Open a popup window with a window.open() passing parameters as \u2018post\u2019\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Open a popup with a window.open passing parameter - SS Blog","description":"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/","og_locale":"en_US","og_type":"article","og_title":"Open a popup with a window.open passing parameter - SS Blog","og_description":"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.","og_url":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2023-01-13T04:52:20+00:00","article_modified_time":"2023-01-13T09:54:25+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/01\/parameters.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Open a popup window with a window.open() passing parameters as \u2018post\u2019","datePublished":"2023-01-13T04:52:20+00:00","dateModified":"2023-01-13T09:54:25+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/"},"wordCount":304,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["parameters","window"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/","url":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/","name":"Open a popup with a window.open passing parameter - SS Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2023-01-13T04:52:20+00:00","dateModified":"2023-01-13T09:54:25+00:00","description":"Target is to open a third-party page but not using query parameters in the URL. And this is to be achieved through javascript.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/open-a-popup-window-with-a-window-open-passing-parameters-as-post\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Open a popup window with a window.open() passing parameters as \u2018post\u2019"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":2113,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6350"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=6350"}],"version-history":[{"count":2,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6350\/revisions"}],"predecessor-version":[{"id":6353,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6350\/revisions\/6353"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/6351"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=6350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=6350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=6350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}