?
Solved

Why does this script not work in this site

Posted on 2014-02-20
2
Medium Priority
?
337 Views
Last Modified: 2014-02-24
I am trying to display some customer reviews on this site.  Its is supposed to auto rotate the reviews. Its built in Dreamweaver. For some reason the below script is not being called. http://basementauthoritiesnh.com/. It should be displaying under Customer Comments

Here is my code:

one the homepage I have div tag

<div id="testimonials" class="transparent_class"></div>

and css for the transparent_class is

transparent_class {
    font-size:13px;
    height:80px;
    width:680px;
}

for the javascript
var Testimonials = [
	['Sample text <br> <b> - John</b>'],
	['Sample text <br> <b> - Jane</b>']
	
				// Note: no comma after last entry
	];
	
var fileInx = 0;
var fadeCnt = 0;
var fadeInc = 5;

function dispTestimonial () {
  document.getElementById("testimonials").innerHTML = Testimonials[fileInx]; // +'<p>'+fadeCnt;
  document.getElementById('testimonials').style.opacity = (fadeCnt/30).toFixed(2);
  document.getElementById('testimonials').style.filter = 'alpha(opacity=' + fadeCnt + ')';
  fadeCnt += fadeInc;
  if (fadeCnt >= 100) { fadeInc *= -1; }
  if (fadeCnt <= 0) {
	fadeInc *= -1;   
    fileInx++;
    fileInx = (fileInx % Testimonials.length);  
  }
}

window.onload = function () {
  dispTestimonial()
  setInterval("dispTestimonial()", 400);
}

Open in new window

I am trying to display what in the  Testimonials

Thanks
0
Comment
Question by:niceoneishere
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39874398
window.onload can be overwritten by an other window.onload (in fact the one present in your body tag)

use this instead :
var Testimonials = [
	['Sample text <br> <b> - John</b>'],
	['Sample text <br> <b> - Jane</b>']
	
				// Note: no comma after last entry
	];
	
var fileInx = 0;
var fadeCnt = 0;
var fadeInc = 5;

function dispTestimonial () {
  document.getElementById("testimonials").innerHTML = Testimonials[fileInx]; // +'<p>'+fadeCnt;
  document.getElementById('testimonials').style.opacity = (fadeCnt/30).toFixed(2);
  document.getElementById('testimonials').style.filter = 'alpha(opacity=' + fadeCnt + ')';
  fadeCnt += fadeInc;
  if (fadeCnt >= 100) { fadeInc *= -1; }
  if (fadeCnt <= 0) {
	fadeInc *= -1;   
    fileInx++;
    fileInx = (fileInx % Testimonials.length);  
  }
}

var f = function() {
	dispTestimonial()
	setInterval(dispTestimonial, 400);
}

if(window.addEventListener) {
	window.addEventListener('load', f, false);
}
else if (window.attachEvent) {
	window.attachEvent('onload', f);
}

Open in new window


https://developer.mozilla.org/en/docs/DOM/element.addEventListener
0
 
LVL 2

Author Closing Comment

by:niceoneishere
ID: 39883923
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question