View Single Post
  #2 (permalink)  
Old 09-12-2008, 08:28 PM
james113's Avatar
james113 james113 is offline
WebProWorld Pro
 
Join Date: Jun 2004
Location: Hillsboro, Illinois
Posts: 145
james113 RepRank 2
Default Re: Java Script Question

I would try taking the first javascript out and placing it in an external .js file and link to it from the head section of each page like this:

1. Copy and paste this portion of your javascript into a text file with any text editor and save as newJSfile.txt:


function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
home_down = newImage("http://www.webproworld.com/images/home-down.jpg");
about_ann_down = newImage("http://www.webproworld.com/images/about-ann-down.jpg");
conservative_issues_down = newImage("http://www.webproworld.com/images/conservative-issues-down.jpg");
faq_down = newImage("http://www.webproworld.com/images/faq-down.jpg");
web_security_down = newImage("http://www.webproworld.com/images/web-security-down.jpg");
contact_us_down = newImage("http://www.webproworld.com/images/contact-us-down.jpg");
subscribe_down = newImage("http://www.webproworld.com/images/subscribe-down.jpg");
american_news_down = newImage("http://www.webproworld.com/images/american-news-down.jpg");
american_blogs_down = newImage("http://www.webproworld.com/images/american-blogs-down.jpg");
conservative_editorials_down = newImage("http://www.webproworld.com/images/conservative-editorials-dow.jpg");
veterans_assistance_down = newImage("http://www.webproworld.com/images/veterans-assistance-down.jpg");
terrorism_watch_down = newImage("http://www.webproworld.com/images/terrorism-watch-down.jpg");
christian_resources_down = newImage("http://www.webproworld.com/images/christian-resources-down.jpg");
preloadFlag = true;
}
}

2. Upload newJSfile.txt to your website.

3. Rename the file to newJSfile.js

4. Then add the code below between the <head> tags to link to your new external javascript file:


<script type="text/javascript" src="http://www.YourSite.com/newJSfile.js"></script>





Upright Headstones
__________________
James Allen

Last edited by james113; 09-12-2008 at 08:37 PM.
Reply With Quote