?
Solved

Why does this script not work in this site

Posted on 2014-02-20
2
Medium Priority
?
321 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 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 1

Author Closing Comment

by:niceoneishere
ID: 39883923
Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 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