Click the button to open a new tab


Nathan Wilson

I want to create a link with a button that opens in a new tab.

The code I'm currently using is currently opening a blank tab and I'm not sure why.

<div class="text text-left">

    <h2>WORK</h2>
    <h1>Title</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pellentesque felis ante, eu convallis sem egestas id.</p>

    <p>Etiam fermentum vestibulum hendrerit. Nam ac felis dolor ultricies varius eget vel arcu.</p>

    <button href="https://www.behance.net" onclick="window.open(this.href); return false;">View Project</button>

</div>

When the button is clicked, the expected result will be to open a new tab (Behance.com) - not a blank tab.

thanks.

Sammy Ahmed Siddiqui

Attributes hrefdo not allow the addition of elements button, instead of hrefjust using data-hrefHTML and JavaScript just change this.hrefit to something like the this.getAttribute('data-href')following:

<div class="text text-left">

    <h2>WORK</h2>
    <h1>Title</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pellentesque felis ante, eu convallis sem egestas id.</p>

    <p>Etiam fermentum vestibulum hendrerit. Nam ac felis dolor ultricies varius eget vel arcu.</p>

    <button data-href="https://www.behance.net" onclick="window.open(this.getAttribute('data-href')); return false;">View Project</button>

</div>

Running the code directly won't work for you due to blocked permissions. You can try this in your own project.

Related


Click the button to open a new tab

Nathan Wilson I want to create a link with a button that opens in a new tab. The code I'm currently using is currently opening a blank tab and I'm not sure why. <div class="text text-left"> <h2>WORK</h2> <h1>Title</h1> <p>Lorem ipsum dolor sit am

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Open new tab on button click using JQUERY

Rajan My scene is like this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also s

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Open new tab on button click using JQUERY

Rajan My scheme is this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also saved

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Open a new tab after button click in AngularJS

Neptune: <button type="button" class="btn btn-primary" ng-click="openTab()">new tab</button> openTab = function () { $http.post('www.google.com'); } What I want is to post a requirement and then open the response html in a new tab when the "openTab" button

Protractor button click and open page in new tab

Sumitomo I am new to protractor. I'm trying to automate a scenario where I click a button and it opens a page in a new tab and then we need to populate the form in the new page and submit it. Problem : When I click the button to open a new page. My tests don't

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Click Primefaces in a new tab on the button to open the page

username i have this <h:outputLink value="http://.....index.html" target="_blank">open</h:outputLink> But it shows up as a link. How to create a similar button? I need the "Open" button. When I press this button I need to open the link in a new tab in the bro

Open new tab on button click using JQUERY

Rajan My scheme is this: I have edit user module. Each user is assigned a base INI file . When we edit a user, we have a drop down menu from which to select his base INI file. After selection, we can save the user. And the ID of the selected file is also saved

Alert on button click and move user to open new tab

Dashan I created a button with a link that opens in a new tab. I also used JavaScript for reminders. Currently this code works fine. But after clicking OK in the Alert, the user stays on the same page. But I want to move the user to the newly opened tab. is it

button click: open a new browser tab and call a function

fiber I have a button which calls a function: Perform an AJAX PHP request to the database Display the retrieved data in a div container scroll to div container with bookmark (#) I want a button to do the same task, but with one action, which is to open a new t

Alert on button click and move user to open new tab

Dashan I created a button with a link that opens in a new tab. I also used JavaScript for reminders. Currently this code works fine. But after clicking OK in the Alert, the user stays on the same page. But I want to move the user to the newly opened tab. is it

Alert on button click and move user to open new tab

Dashan I created a button with a link that opens in a new tab. I also used JavaScript for reminders. Currently this code works fine. But after clicking OK in the Alert, the user stays on the same page. But I want to move the user to the newly opened tab. Is it

When button click code needs to open output on new tab

Ammonium chloride I am using apex 18.1 with database 11g in windows and my page has dynamic actions with the following Executre java script; apex.navigation.redirect('localhost:1234/reports/rwservlet? server=servername.&report=myrep.rdf&userid=user/pwd@link&de

On button click Open file from server in new tab

Confirm 31 I have a button in a modal that should open a sample struct file to submit, which is in my server. I have tried using: <button type="button" class="btn btn-info" style="float: left" onclick="window.open('/some/path/to/file/file.pdf')">A FILE</button

Alert on button click and move user to open new tab

Dashan I created a button with a link that opens in a new tab. I also used JavaScript for reminders. Currently this code works fine. But after clicking OK in the Alert, the user stays on the same page. But I want to move the user to the newly opened tab. is it

Alert on button click and move user to open new tab

Dashan I created a button with a link that opens in a new tab. I also used JavaScript for reminders. Currently this code works fine. But after clicking OK in the Alert, the user stays on the same page. But I want to move the user to the newly opened tab. is it

button click: open a new browser tab and call a function

fiber I have a button which calls a function: Perform an AJAX PHP request to the database Display the retrieved data in a div container scroll to div container with bookmark (#) I want a button to do the same task, but with one action, which is to open a new t

CakePHP open to new tab on click

mark I have a function in my app where user can upload files to web server. These uploaded files will then appear in another page where another type of user can click the link. After clicking the link, a new tab will open and the file will be displayed. But I

CakePHP open to new tab on click

mark I have a function in my app where user can upload files to web server. These uploaded files will then appear in another page where another type of user can click the link. After clicking the link, a new tab will open and the file will be displayed. But I