Open a new tab (window) by clicking a link in jquery


k

I have a web application that displays rows with goand deletebuttons .

If the user clicks go, it should open a new tab/window with a url built from the row data.

How to do this in jquery? What I am doing is:

$('.go').click( function () {
   var wid = {{ wid|tojson|safe }};
   var sid = $(this).prop('id');
   url = $script_root + '/' + wid + '/' + sid;

   // go to url
});

Some updates:

What I'm really tring to do is dynamically update hrefthe <a>element.

<a id="foo" href="#">foo</a>
<script type="text/javascript>
$('#foo').click( function() {
  $(this).prop('href', 'http://www.google.com/');
});
</script>

This does n't work (fiddle : http://jsfiddle.net/6eLjA/ )

karaxuna :

Try this:

window.open(url, '_blank');

This will open in a new tab (if your code is synchronous, in this case it is synchronous. In other cases it will open a window)

Related


Open a new tab (window) by clicking a link in jquery

k I have a web application that displays rows with goand deletebuttons . If the user clicks go, it should open a new tab/window with a url built from the row data. How to do this in jquery? What I am doing is: $('.go').click( function () { var wid = {{ wid|

Open link in new tab or window

Rene Is it possible to open a link a hrefin a new tab instead of the same tab ? <a href="http://your_url_here.html">Link</a> Nason You should add target="_blank"and in the anchor tag rel="noopener noreferrer". E.g: <a target="_blank" rel="noopener noreferrer"

Open link in new tab or window

Rene Is it possible to open a link a hrefin a new tab instead of the same tab ? <a href="http://your_url_here.html">Link</a> Nason You should add target="_blank"and in the anchor tag rel="noopener noreferrer". E.g: <a target="_blank" rel="noopener noreferrer"

Open link in new tab or window

Rene Is it possible to open a link a hrefin a new tab instead of the same tab ? <a href="http://your_url_here.html">Link</a> Nason You should add target="_blank"and in the anchor tag rel="noopener noreferrer". E.g: <a target="_blank" rel="noopener noreferrer"

Clicking a link does not open in a new window

hello universe Please check the link at http://staging.serviceportal.com.au/service05/discovery_2014.do . Please fine "I agree to terms and conditions". When I click on terms and conditions it doesn't open in a new window. . any idea why? The problem is that t

Clicking a link does not open in a new window

hello universe Please check the link at http://staging.serviceportal.com.au/service05/discovery_2014.do . Please fine "I agree to terms and conditions". When I click on terms and conditions it doesn't open in a new window. . any idea why? The problem is that t

Javascript - open link in "new tab" (SAME WINDOW)

to I realize there are already several questions on this topic, but they all seem pretty old... just trying to get an up-to-date answer: Still the standard way to open a new tab in the same browser window: window.open('url', '_blank'); window.focus(); ??? Als

Create link in PDF to open in new window/tab

the fridge I have a PDF document embedded in a webpage with object tags. Is it possible to create a link in a PDF document that opens in a new tab/window? I tried: app.launchURL("www.google.com", true); But not for Chrome. aldhafera.h Yes, it must be built in

Open external link in angulardart in new tab/window

Patrick Cornelissen I'm writing an Angular Dart application that contains some links to other resources on the server. I had a weird experience where some links were "handled" by angular and some were not. For example, in the code, I have two links that are cl

Create link in PDF to open in new window/tab

the fridge I have a PDF document embedded in a webpage with object tags. Is it possible to create a link in a PDF document that opens in a new tab/window? I tried: app.launchURL("www.google.com", true); But not for Chrome. aldhafera.h Yes, it must be built in

Open external link in angulardart in new tab/window

Patrick Cornelissen I'm writing an Angular Dart application that contains some links to other resources on the server. I had a weird experience where some links were "handled" by angular and some were not. For example, in the code, I have two links that are cl

jQuery iframe a link to a new div/tab/window?

King Alexander I have a tough question. All pages are in the same server/portal. I have a page that embeds an iframe from another page using the following code: $('#mydiv').append('<p id="loading">Loading ...</p>'); $('#mydiv').append('<iframe id="myframe" nam

jQuery iframe a link to a new div/tab/window?

King Alexander I have a tough question. All pages are in the same server/portal. I have a page that embeds an iframe from another page using the following code: $('#mydiv').append('<p id="loading">Loading ...</p>'); $('#mydiv').append('<iframe id="myframe" nam

JS Jquery - open link in new tab

Jaime Matos I have this JS in my website to display a custom text message and the message has a hyperlink. However, it opens it in the current window and I want to make sure it opens in a new tab. In this case, I can't figure out how to achieve this. var conce

Open link in new tab using JQuery

Aquarius 24 I have a div and some links in it. I want to open these links in a new tab, so am using the following code: $(".classname").find("a").target = "_blank"; However, it doesn't work. Is there anything I'm missing? Mohit kumar You are doing it wrong, y

Open link in new tab using JQuery

Aquarius 24 I have a div and some links in it. I want to open these links in a new tab, so am using the following code: $(".classname").find("a").target = "_blank"; However, it doesn't work. Is there anything I'm missing? Mohit kumar You are doing it wrong, y

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing happens. PS I am using pyQt5.6 I've tried it on Linux centOs,

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing happens. PS I am using pyQt5.6 I've tried it on Linux centOs,

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing happens. PS I am using pyQt5.6 I've tried it on Linux centOs,

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing is done. PS I am using pyQt5.6 I've tried it on Linux centOs,

Window cannot open new window or tab on external URL link click

Rajish Kapoor I need to open a URL using pyQt5. The page has several links that open new windows. pyQt5 opens a window for the URL, but after clicking the link that should open a new window, nothing is done. PS I am using pyQt5.6 I've tried it on Linux centOs,

JavaScript: How to open link in new tab without window.open()?

Brandon I have a href that I need to open in a new tab and can't use anchor tags because it's from a webgl context. Here's how to accomplish this task: window.open(href, "_blank"); However, the big caveat that comes with it is that the new tab shares a runtim

JavaScript: How to open link in new tab without window.open()?

Brandon I have a href that I need to open in a new tab and can't use anchor tags because it's from a webgl context. Here's how to accomplish this task: window.open(href, "_blank"); However, the big caveat that comes with it is that the new tab shares a runtim

JavaScript: How to open link in new tab without window.open()?

Brandon I have a href that I need to open in a new tab and can't use anchor tags because it's from a webgl context. Here's how to accomplish this task: window.open(href, "_blank"); However, the big caveat that comes with it is that the new tab shares a runtim

JavaScript: How to open link in new tab without window.open()?

Brandon I have a href that I need to open in a new tab and can't use anchor tags because it's from a webgl context. Here's how to accomplish this task: window.open(href, "_blank"); However, the big caveat that comes with it is that the new tab shares a runtim

Open new window via JQuery link

User 7302419 I found some workarounds in this forum but it doesn't work for me. I press a link and a new window should open in a new window. My HTML code is: <!DOCTYPE html> <html lang="sv-se"> <head> <meta charset="UTF-8"> <script src="https://a

Open link in new tab

no mice here I need to open a link <a>in a new tab/window 's tab, do something there and then close it. html code: <body> <a id="uniqueid" href="somelink">I need to open this in a new tab</a> </body> python code: from selenium import webdriver driver = w

Open in new window or tab

Raleigh I would like to open the following in a new window or tab. Currently, it opens in the same window, so after sending the email, the page has to be reloaded. This is part of this page function email_message() { bodytext = document.getElementById("end"

Open in new window or tab

Raleigh I would like to open the following in a new window or tab. Currently, it opens in the same window, so after sending the email, the page has to be reloaded. This is part of this page function email_message() { bodytext = document.getElementById("end"