-1

This is the code currently, I've tried adding target="_Blank" but it still opens in the same tab.

We are using WordPress and this is the code we use in the text box for a button to appear.

button color="extra-color-1" hover_text_color_override="#ffffff" size="large" url="https://www.insideeducation.ca/learning-resources/classroom-learning-resources/elementary-school/#flying-animals-scavenger-hunt"  text="Flying Animals | Scavenger Hunt"]
epascarello
  • 204,599
  • 20
  • 195
  • 236
  • 3
    have you tried `target="_blank"` with a lower case b? – ewhiting Apr 14 '20 at 15:45
  • 1
    Does this answer your question? [How to open link in new tab on html?](https://stackoverflow.com/questions/17711146/how-to-open-link-in-new-tab-on-html) – DCR Apr 14 '20 at 15:45
  • I've edited my answer to include three different ideas for you. Do any of them work? – Run_Script Apr 17 '20 at 12:23

2 Answers2

0

I can't tell you that any of these approaches will work for sure, but there are three methods or workarounds I've thought of that you could try out.

1. Use target="_blank"

I would usually use lower case letters in target attributes. So instead of target="_Blank", you could try target="_blank".

However, this is more likely to be a matter of preference, and I think browsers will most likely accept both of these options.

2. Use some simple javascript

You could use the javascript window.open() function as a workaround for this problem.

Replace target="_Blank" with onclick="window.open('https://www.example.com')" and see if that works any better!

3. Use an anchor tag

At the moment, you seem to be using a button element which looks something like this:

<button color="extra-color-1" ... target="_blank" url="https://...">
  Click here!
</button>

You could wrap an a tag around the button and instead apply the target attribute to that. It may be that target attributes work better directly on anchor tags. Here's what it would look like:

<a href="https://..." target="_blank">
  <button color="extra-color-1" ... >
    Click here!
  </button>
</a>
Run_Script
  • 2,487
  • 2
  • 15
  • 30
0

did you try anchor tag because i think target attribute works pretty well with anchor

arslan
  • 1,064
  • 10
  • 19