0

I need to make a specific link on a page redirect to a different URL than what it currently directs to. The page is https://gatewayrealtynp.idxbroker.com/idx/roster and it's the "View Active Listings" link that I need to redirect for just one of the agents. I should note that I do not have access to the root files.

I have researched and tried several JS methods, but nothing has worked so far. Here is the code that I've most recently tried: https://gist.github.com/Hope0417/05257b6798d1720bd740b09537a655ee. Putting the same <script> code between the opening and closing <head> tags didn't work either. When using this code, it redirects the entire "roster" page to the new URL, which is not what I need to happen.

I've also tried using <meta HTTP-EQUIV="REFRESH" content="0; url=https://gatewayrealtynp.idxbroker.com/i/listings"> between the opening and closing <head> tags, but it does the same thing as the above code. This code between the <head> tags doesn't do anything: <script type="text/javascript"> var oldWesLocation = https://gatewayrealtynp.idxbroker.com/idx/agent/141880/wes-grady; location = https://gatewayrealtynp.idxbroker.com/i/listings; </script>

Thank you in advance for any suggestions/guidance on this. And, please accept my apologies if I've posted my question incorrectly (I'm very new at this).

HopeR
  • 1
  • 1
  • Do you have access to the server itself? Setting a redirect in `.htaccess` will be the simplest way of achieving this. Alternately you could try ```javascript window.onload = function(){ window.location.href="https://gatewayrealtynp.idxbroker.com/i/listings" }; ``` This should redirect the user to the listing page when the window has loaded. – Maneesh Feb 13 '19 at 17:02
  • Possible duplicate of [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) – Marcell Toth Feb 13 '19 at 17:11
  • @Maneesh Unfortunately, I don't have access to the server. With the JavaScript code you suggested, it redirects the entire "roster" page to the new URL, which I don't want to do. What I need to have happen is, on the "roster" page, if someone clicks on the "View Active Listings" link for one specific agent (ex: Wes Grady), I need it to redirect to the new URL. – HopeR Feb 13 '19 at 17:12
  • 1
    @Marcell Toth I have actually checked that question/answer, but none of the answers provided work the way I need. Thank you, though. – HopeR Feb 13 '19 at 17:16
  • @HopeR Are you not able to update the links on the Roster page to point to the new page? – Maneesh Feb 13 '19 at 17:26
  • @Maneesh No, I'm not able to simply update the links on the Roster page (I wish I could!). The main website uses WordPress, but IDX Broker is integrated with it for all of the MLS (Real Estate) stuff, which includes the agents and the Roster page. So, I have to write some custom code in IDX Broker in order to make this work. – HopeR Feb 13 '19 at 17:31

1 Answers1

1

Based of your reply to my comment I now understand what you are trying to achieve.

If you cannot update the HTML directly, Add this javascript to the roster page

let wes = document.querySelectorAll('a[href*="wes-grady"]');
wes.forEach(link => {
   link.href = 'https://gatewayrealtynp.idxbroker.com/i/listings';
});

If you can run this this bit of javascript on the Wordpress site, it will look for all the links that contain the term wes-grady and then switch out the href of just those links to the one you specified.

Maneesh
  • 378
  • 1
  • 10
  • The JS you provided didn't work, unfortunately. I tried it in Wordpress and IDX Broker, but nothing changed. I also placed the code within the `` tags, as well as trying in the `` tags. – HopeR Feb 13 '19 at 18:55