{"id":25138,"date":"2020-04-27T12:15:51","date_gmt":"2020-04-27T09:15:51","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=25138"},"modified":"2020-04-24T12:57:48","modified_gmt":"2020-04-24T09:57:48","slug":"open-link-in-new-tab","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/","title":{"rendered":"JavaScript: Open Link in New Tab"},"content":{"rendered":"\n<p>Major browsers have popup blockers which sometimes prevent sites to open new tabs. This article investigates how popup blockers currently works, what they block and how to overcome problems caused by them.<\/p>\n\n\n\n<p>First chapter gives short overview of popup blockers. The rest of article shows multiple ways how to open new tab and how to work around browsers limitations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Popup Blockers<\/h4>\n\n\n\n<p>For the browser, there is no difference between new tab and popup. Popup blockers treats them the same way. Therefore, this article uses &#8220;new tab&#8221; and &#8220;new window&#8221; interchangeably.<\/p>\n\n\n\n<p>Popup blocker built inside the Firefox is willing to open new tab only from onclick hander. It prevents tab opening from mouse over event, network request response, and from inside script in the body. Instead of opening new tab, firefox will show yellow warning banner which says&nbsp;<code>Firefox prevented this site from opening popup<\/code>. It is possible to turn off the warning, but that requires user action.<\/p>\n\n\n\n<p>Edge works similarly to Firefox, except that banner is white and show on bottom of the window.<\/p>\n\n\n\n<p>Chrome always prevents new tabs from network request response. It mostly prevents also new tabs from on mouse over event and script inside the body. The last two are sometimes created, but I did not found when exactly. Chrome shows small icon in url bar when it refuses to open the new tab. User can click on it and allow popups manually.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Html Link<\/h4>\n\n\n\n<p>The easiest way to create a link that opens in a new tab is to add&nbsp;<code>target=\"_blank\"<\/code>&nbsp;to it. It works in Chrome, Firefox and Edge.<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;a href=\"http:\/\/gooogle.com\" target=\"_blank\"&gt;Normal Link&lt;\/a&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/gooogle.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Normal Link<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">JavaScript<\/h4>\n\n\n\n<p>JavaScript can open new tab using the&nbsp;<code>window.open(URL, name, specs, replace)<\/code>&nbsp;function. The trick is to put&nbsp;<code>'_blank'<\/code>&nbsp;into&nbsp;<code>name<\/code>&nbsp;argument.<\/p>\n\n\n\n<pre class=\"brush:php\">window.open('https:\/\/www.google.com', '_blank');\n<\/pre>\n\n\n\n<p>This works in most, but not all, situations. Most importantly, Edge and Firefox block new tab from network request response handler. When the url have to be loaded from backend, Firefox requires tricks to work.<\/p>\n\n\n\n<p>This chapter has two sections.&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#JavaScriptWhentheUrlisKnown\">First section<\/a>&nbsp;deals with situation when the frontend knows the url.&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#JavaScriptFetchingUrlFromBackend\">Second section<\/a>&nbsp;shows how to open link in new tab when the fronted needs to send network request.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">When the Url is Known<\/h5>\n\n\n\n<p>In this chapter, we will try to open a new tab from mouse click, from timer, from mouse over and from a script inside the body.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Click<\/h6>\n\n\n\n<p>Open new tab from&nbsp;<code>onclick<\/code>&nbsp;attribute of html tag works from Chrome, Firefox and Edge:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;a href=\"#\" onclick=\"\n    window.open('https:\/\/www.google.com', '_blank');\n    return false;\n\"&gt;on click&lt;\/a&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#\">on click<\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Timer Inside Click<\/h6>\n\n\n\n<p>You can also start a timer while handling users onclick method and open a new tab later from the timer. It works in Chrome, Firefox and Edge:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;a href=\"#\" onclick=\"\n    setTimeout(() =&gt; window.open('https:\/\/www.google.com', '_blank'), 500);\n    return false;\n\"&gt;click starts timer&lt;\/a&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html\">click starts timer<\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Mouse Over<\/h6>\n\n\n\n<p>Open new tab from&nbsp;<code>onmouseover<\/code>&nbsp;attribute of an html tag does not work. Firefox and Edge block it all the time. Chrome blocks it most of the time, although blocking is not perfect and the tab occasionally shows up:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;a href=\"#\" onmouseover=\"\n    window.open('https:\/\/www.google.com', '_blank');\n    return false;\n\"&gt;on mouse over&lt;\/a&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html\">on mouse over<\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Timer Inside Mouse Over<\/h6>\n\n\n\n<p>Open new tab from timer started inside&nbsp;<code>onmouseover<\/code>&nbsp;does not work. Firefox and Edge block it all the time. Chrome blocks it most of the time, although blocking is not perfect and the tab shows up once in a while:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;a href=\"#\" onmouseover=\"\nsetTimeout(function() {\n window.open('https:\/\/www.google.com', '_blank');\n} ,500);\nreturn false;\n\"&gt;timer on mouseover&lt;\/a&gt;&lt;\/br&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#\">timer on mouseover<\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Body Onload<\/h6>\n\n\n\n<p>Opening new tab from script in body is blocked by all three browser. Add this inside the body tag to see it:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;script&gt;\n console.log(\"installing\");\n setTimeout(function() {\n  console.log(\"running\");\n  window.open('https:\/\/www.google.com', '_blank');\n }, 500);\n&lt;\/script&gt;\n<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Fetching Url From Backend<\/h5>\n\n\n\n<p>More interesting and useful case is when the web application needs to fetch the url from backend. The straightforward solution does not work, Edge and Firefox block the new tab. However, this use case is too useful to be ignored, so we will build workaround.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">From Request Response<\/h6>\n\n\n\n<p>Opening new tab from request response works only in Chrome. Edge and Firefox shows yellow warning and prevents new tab to open:<\/p>\n\n\n\n<pre class=\"brush:xml\">&lt;script&gt;\nfunction fromHttpRequest() {\n const Http = new XMLHttpRequest();\n const url='https:\/\/jsonplaceholder.typicode.com\/posts';\n Http.open(\"GET\", url);\n Http.send();\n \n Http.onreadystatechange = (e) =&gt; {\n   console.log(Http.responseText)\n   window.open('https:\/\/www.google.com', '_blank');\n }\n}\n&lt;\/script&gt;\n&lt;a href=\"#\" onclick=\"\n    fromHttpRequest();\n    return false;\n\"&gt;from http request&lt;\/a&gt;&lt;\/br&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html\">from http request<\/a><\/p>\n\n\n\n<p>Starting timer from request response does not help. Chrome and Edge will open the tab, but Firefox will show warning instead. I have omitted the example, because it is long and almost the same as timers above.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Workaround 1<\/h6>\n\n\n\n<p>The workaround is to combine javascript interval started from user click, network request and let them communicate through variable.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Network request waits for response. Then it sets the common variable.<\/li><li>The interval periodically checks variable value. It opens new tab once the variable has the response. Then the interval removes itself.<\/li><\/ul>\n\n\n\n<pre class=\"brush:js\">&lt;script&gt;\nfunction intervalListensForRequestResponse() {\n var iHaveTheResponse; \/\/ shared variable\n \n \/\/ send request\n const Http = new XMLHttpRequest();\n const url='https:\/\/jsonplaceholder.typicode.com\/posts';\n Http.open(\"GET\", url);\n Http.send();\n \n Http.onreadystatechange = (e) =&gt; {\n   console.log(Http.responseText)\n   iHaveTheResponse = 'https:\/\/www.google.com';\n }\n \n \/\/ periodically check the variable\n var refreshIntervalId = setInterval(function(){\n    console.log('tick ' + iHaveTheResponse);\n    if (iHaveTheResponse) {\n     window.open(iHaveTheResponse, '_blank')\n     clearInterval(refreshIntervalId);\n    }\n  }, 500);\n return false;\n}\n&lt;\/script&gt;\n&lt;a  href=\"#\" onclick=\"\n    return intervalListensForRequestResponse();\n\"&gt;interval listens for request response&lt;\/a&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#\">interval listens for request response<\/a><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Workaround 2<\/h6>\n\n\n\n<p>If the frontend knows for sure it will have to open new tab and just needs to acquire correct url from backend, you can:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Open new window and keep reference to it.<\/li><li>Send the request.<\/li><li>Set url to newly opened window.<\/li><\/ol>\n\n\n\n<p>The disadvantage of this solution is that new window is opened before the response from backend came back. There is a blank window for few miliseconds. In addition, it is impossible to make backend decide whether the window will be needed or not.<\/p>\n\n\n\n<pre class=\"brush:js\">&lt;script&gt;\nfunction startByOpeningTheWindow() {\n var newTab = window.open(\"\", '_blank');\n if (newTab==null) {\n  return ;\n }\n \n \n \/\/ send request\n const Http = new XMLHttpRequest();\n const url='https:\/\/jsonplaceholder.typicode.com\/posts';\n Http.open(\"GET\", url);\n Http.send();\n \n Http.onreadystatechange = (e) =&gt; {\n   console.log(Http.responseText);\n   newTab.location.href = 'https:\/\/www.google.com';\n }\n return false;\n}\n&lt;\/script&gt;\n&lt;a href=\"#\"\n      onclick=\"startByOpeningTheWindow();\"\n&gt;first open the window, change url later&lt;\/a&gt;&lt;\/br&gt;\n<\/pre>\n\n\n\n<p>This is how it renders:&nbsp;<a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html#\">first open the window, change url later<\/a><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Few Notes on Open Function<\/h5>\n\n\n\n<p>Communication between original window and new tab is possible if they have the same origin. If they show pages from different domains, the communication is blocked by the browser due to Same Origin Policy rules. It ends with&nbsp;<code>Error: uncaught exception: Permission denied to get property&nbsp;<\/code>error.<\/p>\n\n\n\n<p>The&nbsp;<code>window.open<\/code>&nbsp;function returns reference to the tab that was just opened. The original page can use it to call functions inside newly opened tab. If the Firefox popup blocker blocked the popup, the function returns&nbsp;<code>null<\/code>. You can use this to check whether the new tab was blocked. This method works only for built-in popup blocker, it does not work for ad-blocking addons.<\/p>\n\n\n\n<p>New tab has the&nbsp;<code>opener<\/code>&nbsp;property which can be used to call functions inside the main window. It also has the&nbsp;<code>closed<\/code>&nbsp;property. Main window can use it to check whether the child tab was open or not.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">All Examples<\/h4>\n\n\n\n<p>All tested cases are on&nbsp;<a href=\"https:\/\/sommeri.github.io\/simple-samples-js\/open-link-in-new-tab\/open-link-in-new-tab.html\">this page<\/a>.<\/p>\n\n\n\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Maria Jurcovicova, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">WCG program<\/a>. See the original article here: <a href=\"http:\/\/meri-stuff.blogspot.com\/2020\/04\/open-link-in-new-tab.html\" target=\"_blank\" rel=\"noopener noreferrer\">Open Link in New Tab<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Major browsers have popup blockers which sometimes prevent sites to open new tabs. This article investigates how popup blockers currently works, what they block and how to overcome problems caused by them. First chapter gives short overview of popup blockers. The rest of article shows multiple ways how to open new tab and how to &hellip;<\/p>\n","protected":false},"author":17678,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-25138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript: Open Link in New Tab - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript: Open Link in New Tab - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-27T09:15:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Maria Jurcovicova\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Maria Jurcovicova\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\"},\"author\":{\"name\":\"Maria Jurcovicova\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/b89c085bddd0791764ff25d173d32f99\"},\"headline\":\"JavaScript: Open Link in New Tab\",\"datePublished\":\"2020-04-27T09:15:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\"},\"wordCount\":1073,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\",\"name\":\"JavaScript: Open Link in New Tab - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2020-04-27T09:15:51+00:00\",\"description\":\"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript: Open Link in New Tab\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/b89c085bddd0791764ff25d173d32f99\",\"name\":\"Maria Jurcovicova\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/036cc830ddb6b2d9385310d0eda5091365721bd14304c113c8548d6e508b5feb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/036cc830ddb6b2d9385310d0eda5091365721bd14304c113c8548d6e508b5feb?s=96&d=mm&r=g\",\"caption\":\"Maria Jurcovicova\"},\"sameAs\":[\"http:\/\/meri-stuff.blogspot.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/maria-jurcovicova\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript: Open Link in New Tab - Web Code Geeks - 2026","description":"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.","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:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript: Open Link in New Tab - Web Code Geeks - 2026","og_description":"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2020-04-27T09:15:51+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Maria Jurcovicova","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Maria Jurcovicova","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/"},"author":{"name":"Maria Jurcovicova","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/b89c085bddd0791764ff25d173d32f99"},"headline":"JavaScript: Open Link in New Tab","datePublished":"2020-04-27T09:15:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/"},"wordCount":1073,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/","name":"JavaScript: Open Link in New Tab - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2020-04-27T09:15:51+00:00","description":"Interested to learn about Tab? Check our article explaining how popup blockers currently works, what they block and how to overcome problems caused by them.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/open-link-in-new-tab\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript: Open Link in New Tab"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/b89c085bddd0791764ff25d173d32f99","name":"Maria Jurcovicova","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/036cc830ddb6b2d9385310d0eda5091365721bd14304c113c8548d6e508b5feb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/036cc830ddb6b2d9385310d0eda5091365721bd14304c113c8548d6e508b5feb?s=96&d=mm&r=g","caption":"Maria Jurcovicova"},"sameAs":["http:\/\/meri-stuff.blogspot.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/maria-jurcovicova\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/25138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/17678"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=25138"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/25138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=25138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=25138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=25138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}