1

I would want to create an tag with target attribute set to blank, but without actually moving me to the opened page, but rather staying on the page it was opened on.

Snowshoot
  • 173
  • 1
  • 4
  • 16
  • 1
    That's typically a browser setting that you can't affect – j08691 Jun 07 '19 at 15:12
  • Possible duplicate of [Open a new tab in the background?](https://stackoverflow.com/questions/10812628/open-a-new-tab-in-the-background) – Quentin Jun 07 '19 at 15:25

2 Answers2

2

I hope this helps.

<!DOCTYPE html>
<html>
   <head>
      <title>Page Title</title>
      <style></style>
   </head>
   <body>
      <a href="https://google.com/" trueblank="true" >Click Me</a>
      <script>
         var links = document.querySelectorAll("a");
         links.forEach(function(each) {
            each.onclick = function(ev) {
                if(this.getAttribute("trueblank") == "true") {
                    ev.preventDefault();
                    window.open(this.href);
                 }
             }
         });
      </script>
   </body>
</html>
Space
  • 39
  • 8
0

following JS code below opens a new window on your current window and user remains on the first page yet

  window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
Iman Emadi
  • 421
  • 4
  • 14