Knowledge Base  
Login To Ticket System  

Knowledge Base
Knowledge Base

View Article

Using javascript code on store pages

I have a question about using javascript on my front page.  In order to run a few demos we have, I need to use some javascript I was given to open the viewer and then the movie.
This works fine when I put it into the site, but then the next day it doesn't work.  Even if I don't change javascript allowed?
Is it in some way "compressed" and therefore unable to work?
Thanks so much for your help on this one - again!

I just checked your store's front page and see what you mean. It looks like the javascript is mangled up. It would be better if you added the javascript code (especially the ones with longer javascript code into an external file. Just save the actual code (without the <script language="javascript"></script>) into a plain text file and name it as somename.js. Upload that file using the upload additional file function.

Then, where you currently have

<script language="javascript">
some long javascript code;.......

replace it with

<script language="javascript" src="files/somename.js"></script>

This is called using an external javascript file. Since the built-in HTML editor can sometimes mess up javascript code (although not often), consider having your code in an external .js file and call the external file instead of embedding the entire javascript code into your page.

Category : Miscellaneous
Author : charlestang (Charles Tang)
Date : --

All rights reserved. Copyright 2019.