Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
¿Cómo hacer que el enlace HTML Anchor haga 2 cosas diferentes?

¿Cómo puedo hacer que un ancla haga dos cosas,

  1. Llevar al usuario a la misma página
  2. Abre una nueva pestaña a otro enlace.
 <a href="http://www.example.com/#test" target="_blank" onclick="window.open('http://www.example.com'); window.open('http://www.example.com');">TEST</a>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede lograr esto al tener dos eventos en un solo elemento, por ejemplo:

 document.getElementById("test").addEventListener("click",function(){ window.open('http://www.yahoo.com', '_self'); window.open('http://www.google.com', '_blank'); })
 <a id="test">click me</a>

Entonces, el primer enlace se abrirá en la misma página y el otro se abrirá en una nueva página en blanco.

about 4 years ago · Juan Pablo Isaza Report

0

puede controlar el comportamiento de su enlace agregando un oyente y evitar la acción predeterminada, ejemplo:

 const link = document.querySelector("a"); // it would be good to add some id to your html anchor tag const url = "http://www.example.com/#BINANCVIDEO"; // tab url you want to open link.addEventListener("click", event => { event.preventDefault(); // stop default redirect window.scrollTo(0,document.body.scrollHeight); // scroll user to bottom window.open(url, '_blank'); // you can add .focus() to this line if you prefer that });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!