0

Following js code refreshing the page to the url, but i wanna make it open in a new tab.

    case"example1":  case"example2":
     l.after('<meta http-equiv="refresh" content="0; url=https://example.com" /> Opening...'); ```
Can anyone help me about that?
0

1 Answer 1

-1

Steps for opening a link in a new tab:

  1. Create an a element
  2. Set the href ( "https://example.com" )
  3. Set target to "_blank"
  4. Click on the link

Code:

<button onclick="myFunction()">Open</button>
<script>
function myFunction() {
  link = document.createElement("a")
  link.href = "https://example.com"
  link.target = "_blank"
  link.click()
}
</script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.