Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

New Pages Aren't Displaying Custom Javascript? Rate Topic   - - - - -

 
  • iscariot
  • Newbie
  • Members
  • Join Date: 28-Jan 16
  • 9 posts

Posted 01 February 2016 - 05:01 PM #1

I am trying to create an order tracking page which uses an Aftership tracking button that is coded in JavaScript. Although adding extra HTML onto the page works and is displayed, when I try to input some JS, nothing shows up.

 

Here is the snipped I am trying to add, for reference:

 

<p><code></code>
</p>
<div id="as-root">
</div>&lt;code&gt;(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n))return;r=e.createElement(t);r.id=n;r.src="//button.aftership.com/all.js";i.parentNode.insertBefore(r,i)})(document,"script","aftership-jssdk")&lt;/code&gt;<code><code>
<div data-size="large" data-domain="track.aftership.com">
</div></code></code>

 

Has anyone experienced this sort of problem before?

 

Any help would be greatly appreciated!



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11815 posts

Posted 01 February 2016 - 11:07 PM #2

You might want to use <script> instead of <code> tag.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21077 posts

Posted 02 February 2016 - 07:58 AM #3

How do you add this code? Do not forget to switch WYSIWYG editor to the source code mode also!


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • iscariot
  • Newbie
  • Members
  • Join Date: 28-Jan 16
  • 9 posts

Posted 02 February 2016 - 05:24 PM #4

I inserted the code directly into the description field when editing the page, without clicking the < > button (which is what Aftership recommended). The front-end just displays the code itself, and not the tracking button itself.

 

I have tried inserting it into the HTML field instead (the < > part), but that doesn't display anything on the front-end either.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11815 posts

Posted 02 February 2016 - 08:11 PM #5

Again, suggest you use <script> tags instead of <code> tags if you want your javascript to execute.  The <code> tags are used to format code.  I.e. like a <pre> tag where it recognizes whitespace and newlines.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21077 posts

Posted 03 February 2016 - 09:28 AM #6

Tony is right. For example, script tags are used here:

 

https://aftership.us...tton-to-magento

 

Do not forget about source code mode.


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)