Solved

Why does this script not work in this site

Posted on 2014-02-20
2
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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 1

Author Closing Comment

by:niceoneishere
ID: 39883923
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

697 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