PDA

View Full Version : Spry Menu Not Displaying External Javascripts


MikeyRitz
11-19-2012, 09:04 PM
Hi all,

Sorry for sounding daft, but I'm pretty new to coding.

I wish to place the few javascript functions that I use on my website into one external file. I've read this is better practice as I initially placed them all on each webpage.

The external javascript file looks like this:

<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20927289-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="jquery.magnifier.js">

/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>

<!-- Begin Web-Stat code 2.0 http -->
<script type="text/javascript" src="http://server4.web-stat.com/wtslog.pl?al230354,3"></script>
<noscript></noscript>
<!-- End Web-Stat code v 2.0 -->

I just cut and pasted each snippet of javascript out of the page and placed it in a separate file which I named javascript.js

As you can imagine, there are syntax errors flying up with the code.

I placed this snippet on the main webpage in order to link to the external js code:

<script type="text/javascript" src="javascript.js"></script>

The spry drop down menus ceased working so for now I have pasted the two relevant spry scripts back on to the page.

Ultimately, I wish to have all the scripts on their own external page.

My website is www.itsamodthing.com

Any help would be greatly appreciated by this newbie.

gentleone
11-20-2012, 12:52 PM
If you combine javascript files, then you must not include <script type="text/javascript" src="somejavascriptfile.js"></script> tags in your combined file. Just copy only the content of those files and paste that in your combined file.

MikeyRitz
11-20-2012, 07:45 PM
Thanks for taking the time to reply gentleone. Very much appreciated.