Announcement

Collapse
No announcement yet.

Javascript ptoblem on home page when adding TrustPilot code.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Javascript ptoblem on home page when adding TrustPilot code.

    Hello

    I have added some third party javascript to the home page on a client's site. The code is from Trustpilot and is supposed to pull in Trustpilot reviews onto the page.

    It works fine on all pages generated by Actinic except the home page. The problem is similar to the problem discussed in this thread: http://community.sellerdeck.com/showthread.php?t=47718

    The javascript I am trying to add is as follows:
    ==========

    <script type="text/javascript">
    (function(){var a="https:"==document.location.protocol?"https://ssl.trustpilot.com":"http://s.trustpilot.com",b=document.createElement("script");b.type="text/javascript";b.async=true;b.src=a+"/tpelements/tp_elements_all.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)})();
    </script>

    ===========

    When generating the home page, Actinic (or should I say "SellerDeck"!!) changes the above to the following:

    =========
    <script type="text/javascript">

    (function(){var a="https:"==document.location.protocol?"https://ssl.trustpilot.com":"http://s.trustpilot.com",b=document.createElement("script");b.type="text/javascript";b.async=true;b.src=a + "acatalog//tpelements/tp_elements_all".js;var c=document.getElementsByTagName("script")'<Actinic:Variable Name = '0'/>';'c.parentNode.insertBefore(b,c)'})();

    </script>

    ==========
    Note the addition of the 'acatalog.' path and the 'Actinic:Variable Name'.

    I need to stop the above from being added by Actinic. Alas, my knowledge of Javascript is rather lacking.

    Would anyone with better knowledge than me mind telling me how I can fix this please.

    Many thanks

    Brian
    UK Work Store

    #2
    Try placing spaces after and before all square brackets.

    So in your case replace:
    ...script")[0];c.parentNode...
    with:
    ...script")[ 0 ];c.parentNode...

    You may also need to munge the path that you are having problems with. Hopefully someone else can assist with that part for you.

    Comment


      #3
      Duncan has a solution to your first problem. The second is trickier as Actinic detects src= and amends such code.. I'd suggest moving all the Trustpilot code to a file "trustpilot.js" in your Site folder and just load that file. I.e:

      Put this in trustpilot.js in your Site folder:
      Code:
      (function(){var a="https:"==document.location.protocol?"https://ssl.trustpilot.com":"http://s.trustpilot.com",b=document.createElement("script");b.type="text/javascript";b.async=true;b.src=a+"/tpelements/tp_elements_all.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)})()
      And replace the code in your Overall Layouts with:
      Code:
      <script type="text/javascript" src="trustpilot.js"></script>
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        That works!

        Many thanks for your help.

        Regards

        Brian
        UK Work Store

        Comment

        Working...
        X