Redirect 301 in a new tab/window

Jon Imms
Jon Imms used Ask the Experts™
on
Hi All,

I am trying to figure out how to get a 301 redirect in Wordpress to open in a new window?

I am using the Simple 301 Redirect tool with Wordpress

My website -- On the sidebar, I have a redirect in place for the Apply Now link. The only problem, is it opens in the same window, I'd like it to redirect to the new site in a new tab/window.  

Is this possible, and if so, how?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Lucas BishopMarketing Technologist

Commented:
Target the window to "_blank":
https://html.com/attributes/a-target/#a_target8221_blank8221_Open_in_New_Browser_Tab_or_Window

Here is your current code:
<a href="https://cheerful-spiders.flywheelsites.com/careers/company-drivers/apply-now/">Apply Now</a>

Open in new window


With target _blank:
<a href="https://cheerful-spiders.flywheelsites.com/careers/company-drivers/apply-now/" target="_blank">Apply Now</a>

Open in new window

Jon ImmsWeb Developer

Author

Commented:
I understand  target="_blank.

For this though, The site automatically creates the pages menu in the sidebar. I'm then redirecting the link to another site using 301. so i cannot use target="_blank
Lucas BishopMarketing Technologist

Commented:
Targeting is how this is done. It sounds like your issue is actually with the system hat manages your navigation. Is there no way to specify a target in the system that manages your navigation? That's what you need to be addressing.
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
You can bolt on a JavaScript event handler that will work against your rendered menu. Something like this
$('.nested_nav').on('click','.page_item .page-item-95 a', function(e) {
  e.preventDefault();
  var url = this.href;
  window.open(url,'_blank');
});

Open in new window


Note, I have used page-item-95 as that is the class that is shown in the rendered page - if you change your menu this class may change which means the script will have to change.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial