CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Javascript to change web hyperlinks

  1. #1
    Join Date
    Feb 2017
    Posts
    1

    Javascript to change web hyperlinks

    Hi Guys,

    Currently using sharetribe to host a marketplace with a separate landing page on wordpress as follows:

    Sharetribe:
    https://listings.quipmo.com/

    Wordpress:
    http://quipmo.com/

    We are able to insert custom css and java into an editor section in sharetribe and previously used the below code to change the hyperlink reference of different sections of the website back to the wordpress site.

    Code:
    <script>
    window.onload = function() {
    
      $('header a[href="/"]').click(function(e) {
        e.preventDefault();
        self.location = "https://quipmo.com/";
      });
    
      $('header a[href="/en/user_feedbacks/new"]').click(function(e) {
        e.preventDefault();
        self.location = "http://quipmo.com/contact-us/";
      });
    
      $('header a[href="/en/infos/about"]').click(function(e) {
        e.preventDefault();
        self.location = "http://quipmo.com/bit-about-us/";
      });
    
      $('header .header-toggle-menu-menu a').each(function(index) {
        if($(this).text().trim() == 'Browse Listings') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(1)'))
        }
        if($(this).text().trim() == 'About') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(2)'))
        }
        if($(this).text().trim() == 'Trust and Safety') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(3)'))
        }
        if($(this).text().trim() == 'Standards and Expectations') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(4)'))
        }
        if($(this).text().trim() == 'Help Centre') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(5)'))
        }
        if($(this).text().trim() == 'FAQs') {
          $(this).attr('target','_self')
          $(this).insertBefore($('header .header-toggle-menu-menu a:eq(6)'))
        }
      })
    }
    </script>
    Unfortunately sharetribe recently changed its layout/code and the above code now no-longer works.

    Hoping someone might be able to point us in the right direction to get it working again?

    Cheers
    Last edited by PeejAvery; February 23rd, 2017 at 11:31 PM. Reason: Added code tags

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: Javascript to change web hyperlinks

    Well, if they made code changes, you would have to know exactly what changes they made. Did they implement JavaScript that is loading after your scripting? If so, that limits you without creating timers or events.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)