Open a new tab when the link button is clicked


username

I am using the code below to generate a button with a link. But the problem is that it opens in the same tab. I want it to open in a new tab. Can someone suggest me a method that works on most browsers.

<form>
   <input TYPE="button" VALUE="Home Page"
    onclick="window.location.href='http://www.wherever.com'"> 
</form>

Also please suggest if we have a better way to do this.

Thanks in advance.

riad

Since this is JavaScript, you need to use it like this:

<form>
   <input TYPE="button" VALUE="Home Page"
    onclick="window.open('http://www.wherever.com');"> 
</form>

Related


Open a new tab when the link button is clicked

username I am using the code below to generate a button with a link. But the problem is that it opens in the same tab. I want it to open in a new tab. Can someone suggest me a method that works on most browsers. <form> <input TYPE="button" VALUE="Home Page"

Open new tab when button is clicked

yoav.str Using wicket I want to open a new tab when a button or link is clicked, how can I achieve this? What I managed to do is open it in a popup window like this: PopupSettings popupSettings = new PopupSettings("popuppagemap").setLeft(0).setHeight(500).se

Open new tab when button is clicked

yoav.str Using wicket I want to open a new tab when a button or link is clicked, how can I achieve this? What I managed to do is open it in a popup window like this: PopupSettings popupSettings = new PopupSettings("popuppagemap").setLeft(0).setHeight(500).se

Open URL in new browser tab when HTML button is clicked

Yousef Rahimy Akhondzadeh I'm designing a website using CodeIgniter and I want to open some URLs when the user clicks a button (the URL must open in a new tab). I use this code and it works when you want to open the URL in the same tab, but I want the URL to o

Button to open link in new tab

Alex Hawking I'm building a website and I want to open a new tab at a specific address when a button is clicked. Here is the html of my button: <button id="AsDownload" onclick="AsDownload();">Download</button> Here is my javascript: function AsDownload(){

Button to open link in new tab

Alex Hawking I'm building a website and I want to open a new tab at a specific address when a button is clicked. Here is the html of my button: <button id="AsDownload" onclick="AsDownload();">Download</button> Here is my javascript: function AsDownload(){

Button to open link in new tab

Alex Hawking I'm building a website and I want to open a new tab at a specific address when a button is clicked. Here is the html of my button: <button id="AsDownload" onclick="AsDownload();">Download</button> Here is my javascript: function AsDownload(){

How to open a new html page with a link when a button is clicked

Priyanshu So, what I want to do is to open the URL I provide and at the hrefsame time open a new html page. Click on the button and it will point to the URL in a new window target="_blank". But what I want to do is to open the link in a new window and open a n

How to open a new html page with a link when a button is clicked

Priyanshu So, what I want to do is to open the URL I provide and at the hrefsame time open a new html page. Click on the button and it will point to the URL in a new window target="_blank". But what I want to do is to open the link in a new window and open a n

How to open a new html page with a link when a button is clicked

Priyanshu So, what I want to do is to open the URL I provide and at the hrefsame time open a new html page. Click on the button and it will point to the URL in a new window target="_blank". But what I want to do is to open the link in a new window and open a n

How to open a new html page with a link when a button is clicked

Priyanshu So, what I want to do is to open the URL I provide and at the hrefsame time open a new html page. Click on the button and it will point to the URL in a new window target="_blank". But what I want to do is to open the link in a new window and open a n

How to open a new html page with a link when a button is clicked

Priyanshu So, what I want to do is to open the URL I provide and at the hrefsame time open a new html page. Click on the button and it will point to the URL in a new window target="_blank". But what I want to do is to open the link in a new window and open a n

How to open link in new tab when using css button

Nina Norshard Here is my current code: <a href="https://www.google.com" target="_blank" style="font-size:150%;color:#fa5252;">GOOGLE</a><br><br> I wanted it to be a button, so I replaced mine with: <button onclick="window.open='https://www.google.com'" class=

Open new tab when div is clicked Angular

pad I'm working on an angular project and my problem is that I want to open a new tab when I click on a div, but it doesn't work for me. it is <a>. Can someone help me? Here is my code: <div class="application" target="_blank" routerLink="/home"> <img cl

Open new tab when div is clicked Angular

pad I'm working on an angular project and my problem is that I want to open a new tab when I click on a div, but it doesn't work for me. it is <a>. Can someone help me? Here is my code: <div class="application" target="_blank" routerLink="/home"> <img cl

Open new tab when div is clicked Angular

pad I'm working on an angular project and my problem is that I want to open a new tab when I click on a div, but it doesn't work for me. it is <a>. Can someone help me? Here is my code: <div class="application" target="_blank" routerLink="/home"> <img cl

How to open new tab with link button?

Ohmi I use a linkbuttonin the gridviewcontrol . I want to open the data into a new tab target="_blank". I try to set . But it doesn't work. I try to do this. Here is my source code: <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="<

HTML open link in new tab button

User 13710075 I'm trying to make a button to lead to a page in HTML, except for what I'm using to host a website running inside an iframe, I can make a button to lead to a page, but it will refuse to load because it's in an iframe, So I need to find a way to m

How to open a new window when a button is clicked?

Rafael Leonardo Carvajal I'm learning javascript, I'm using visual studio code and node.js I want to create a recorder, when a button is pressed, I need to open a new window, I'd really like to learn how to do that. I have this code and nothing happens when I

How to open a new activity when a button is clicked?

username I'm making an android app and I want it so that when someone clicks a button in the main menu activity they will go to the corresponding activity. Currently, my code is: Button in menu xml: <Button android:layout_width="wrap_content" android:layout_he

How to open a new activity when a button is clicked?

username I'm making an android app and I want it so that when someone clicks a button in the main menu activity they will go to the corresponding activity. Currently, my code is: Button in menu xml: <Button android:layout_width="wrap_content" android:layout_he

Open link in new tab when user clicks

greased I want to create a jQuery script that opens a specific url in a new tab if the user clicks somewhere (no matter where it is). After that, the user should be able to click anywhere without having to get a new tab every time they click. Unfortunately, I

Open link in new tab when user clicks

greased I want to create a jQuery script that opens a specific url in a new tab if the user clicks somewhere (no matter where it is). After that, the user should be able to click anywhere without having to get a new tab every time they click. Unfortunately, I

How to open a clicked link in a new tab via Tampermonkey?

Crab Nebula So I have what seems to be a simple question. I am trying to automatically open a specific link on a page using the following code: // ==UserScript== // @name AutoClicker // @include https://example.com/* // @require http://ajax.googleapis.co