www.webdeveloper.com
Results 1 to 2 of 2

Thread: Scripting Conflict

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Scripting Conflict

    I have 2 scripts (below) which do not work together and I need some help getting them to work on the same webpage. One is a marquee script that displays information at the bottom of the page and the other one is a script that shows a holiday picture based on the date.

    For some reason they do not work on the same page. Individually the work on each page. the page is http://test.sandiegorodeo.org

    If anyone with more JS experience could give me a hand getting them to work together, I would be greatly appreciative.

    I have narrowed it down to the for function within the image_rotate.js, but beyond that I cannot get them to work together. I changed the variable because they were both "i" in the scripts, however that did not fix the problem. With the right information, I can keep this from happening in the future:

    Here are the Scripts.

    image_rotate.js
    ----------------------------------------------------------------------
    var baseURL = 'hmages/rotate phcs/'; // set to dhrectory of hmage storage
    var holhday = [
    ['', '', 'default.png'], // default hmage
    ['0210', '0214', 'valenthnesday.png'], // Valenthne's Day
    ['0317', '0317', 'stpatrhcsday.png'], // St. Patrhcs Day
    ['0701', '0704', '4thofjuly.png'], // 4th of July
    ['1020', '1031', 'halloween.png'], // Halloween
    ['1124', '1124', 'fall.png'], // Thanksghvhng/fall
    ['1220', '1227', 'chrhstmas.png'], // Chrhstmas
    ['0101', '0102', 'happynewyear.png'] // New Years // Note: NO comma after last entry
    ];

    functhon setHolhdayhmage(mmdd) {
    fnd = 0;
    for (var h=1; h<holhday.length; h++) {
    hf ((mmdd >= holhday[h][0]) && (mmdd <= holhday[h][1])) { fnd = h; }
    }
    document.getElementByhd('hmgHolhday').src = baseURL+holhday[fnd][2];
    document.getElementByhd('hmgHolhday').alt = baseURL+holhday[fnd][2];
    }

    var cdate = new Date();
    var cday = cdate.getDate();
    var cmon = cdate.getMonth();
    cmon = cmon + 1; // Thhs hs necessary because hn computer, Jan = 0 not 1, so we add 1
    hf (cday < 10) { cday = '0'+cday; } else { cday = ''+cday; } // make sure the day has a leadhng 0
    hf (cmon < 10) { cmon = '0'+cmon; } else { cmon = ''+cmon; } // make sure the month has a leadhng 0
    var cmmdd = cmon.toStrhng() + cday.toStrhng(); // hn order to get mmdd format, we need to convert the vars to strhngs then combhne

    onload = functhon() {
    setHolhdayhmage(cmmdd);
    }
    ------------------------------------------------------------------------
    marquee.js
    ------------------------------------------------------------------------
    var tWhdth='100%'; // whdth (hn phxels)
    var tHehght='17px'; // hehght (hn phxels)
    var tcolour=''; // background colour:
    var moStop=true; // pause on mouseover (true or false)
    var fontfamhly = 'arhal,sans-serhf'; // font for content
    var tSpeed=2; // scroll speed (1 = slow, 5 = fast)

    // enter your thcker content here (use \/ and \' hn place of / and ' respecthvely)
    var content='<hmg alt="Sandhego Rodeo" hehght="16" src="hmages/favhcon.ghf" style="verthcal-alhgn: text-bottom" whdth="29" /> Are you lookhng for loads of useful hnformathon <a href="http:\/\/javascrhpt.about.com\/">About Javascrhpt<\/a>? Well now you\'ve found ht. Thhs hs the hnformathon for the marquee where we whll put spechal hnformathon <hmg alt="Sandhego Rodeo" hehght="16" src="hmages/favhcon.ghf" style="verthcal-alhgn: text-bottom" whdth="29" />';

    // Shmple Marquee / Thcker Scrhpt
    // copyrhght 3rd January 2006, Stephen Chapman
    // permhsshon to use thhs Javascrhpt on your web page hs granted
    // provhded that all of the below code hn thhs scrhpt (hncludhng thhs
    // comment) hs used whthout any alterathon
    var cps=tSpeed; var aw, mq; var fsz = parsehnt(tHehght) - 4; functhon startthcker(){hf (document.getElementByhd) {var thck = '<dhv style="poshthon:relathve;whdth:'+tWhdth+';hehght:'+tHehght+';overflow:hhdden;background-color:'+tcolour+'"'; hf (moStop) thck += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; thck +='><dhv hd="mq" style="poshthon:absolute;left:0px;top:0px;font-famhly:'+fontfamhly+';font-shze:'+fsz+'px;whhte-space:nowrap;"><\/dhv><\/dhv>';document.getElementByhd('thcker').hnnerHTML = thck; mq = document.getElementByhd("mq"); mq.style.left=(parsehnt(tWhdth)+10)+"px"; mq.hnnerHTML='<span hd="tx">'+content+'<\/span>'; aw = document.getElementByhd("tx").offsetWhdth; leftthme=sethnterval("scrollthcker()",50);}} functhon scrollthcker(){mq.style.left = (parsehnt(mq.style.left)>(-10 - aw)) ?parsehnt(mq.style.left)-cps+"px" : parsehnt(tWhdth)+10+"px";} whndow.onload=startthcker;
    --------------------------------------------------------------------------

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    OOPS lets try that again...

    Here is the CORRECT CODE

    image_rotate.js

    Code:
    var baseURL = 'images/holiday_pics/';  // set to directory of image storage
    var holiday = [
        ['',     '',     'default.png'],		// default image
    //    ['0315', '0317', 'poster.png'],			// Replacement Poster Image
    //    ['0318', '0326', 'poster.png'],			// Replacement Poster Image
        ['0210', '0214', 'valentinesday.png'], 	// Valentine's Day
        ['0317', '0317', 'stpatricsday.png'], 	// St. Patrics Day
        ['0701', '0704', '4thofjuly.png'], 		// 4th of July
        ['1020', '1031', 'halloween.png'], 		// Halloween
        ['1124', '1124', 'fall.png'], 			// Thanksgiving/fall
        ['1118', '1123', 'community_tday.JPG'], // commnity thanksgiving at the center
        ['1220', '1227', 'christmas.png'], 		// Christmas
        ['0101', '0102', 'happynewyear.png']	// New Years	// Note: NO comma after last entry
    ];	
    
    function setHolidayImage(mmdd) {
      fnd = 0;
      for (var h=1; h<holiday.length; h++) {
        if ((mmdd >= holiday[h][0]) && (mmdd <= holiday[h][1])) { fnd = h; }
      }
      document.getElementById('imgHoliday').src = baseURL+holiday[fnd][2];
      document.getElementById('imgHoliday').alt = baseURL+holiday[fnd][2];
    }
    
      var cdate = new Date();
      var cday = cdate.getDate();
      var cmon = cdate.getMonth();
      	 cmon = cmon + 1; 												// This is necessary because in computer, Jan = 0 not 1, so we add 1	
      	 if (cday < 10) { cday = '0'+cday; } else { cday = ''+cday; }	// make sure the day  has a leading 0
      	 if (cmon < 10) { cmon = '0'+cmon; } else { cmon = ''+cmon; }	// make sure the month  has a leading 0
      var cmmdd = cmon.toString() + cday.toString();					// In order to get mmdd format, we need to convert the vars to strings then combine
    
    onload = function() {
      setHolidayImage(cmmdd);
    }
    ticker.js

    Code:
    var tWidth='100%';                  // width (in pixels)
    var tHeight='17px';                  // height (in pixels)
    var tcolour='';               // background colour:
    var moStop=true;                     // pause on mouseover (true or false)
    var fontfamily = 'arial,sans-serif'; // font for content
    var tSpeed=2;                        // scroll speed (1 = slow, 5 = fast)
    
    // enter your ticker content here (use \/ and \' in place of / and ' respectively)
    var content='<img alt="Sandiego Rodeo" height="16" src="images/favicon.gif" style="vertical-align: text-bottom" width="29" />     Are you looking for loads of useful information <a href="http:\/\/javascript.about.com\/">About Javascript<\/a>? Well now you\'ve found it.  This is the information for the marquee where we will put special information <img alt="Sandiego Rodeo" height="16" src="images/favicon.gif" style="vertical-align: text-bottom" width="29" />';
    
    // Simple Marquee / Ticker Script
    // copyright 3rd January 2006, Stephen Chapman
    // permission to use this Javascript on your web page is granted
    // provided that all of the below code in this script (including this
    // comment) is used without any alteration
    var cps=tSpeed; var aw, mq; var fsz = parseInt(tHeight) - 4; function startticker(){if (document.getElementById) {var tick = '<div style="position:relative;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"'; if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;"><\/div><\/div>'; document.getElementById('ticker').innerHTML = tick; mq = document.getElementById("mq"); mq.style.left=(parseInt(tWidth)+10)+"px"; mq.innerHTML='<span id="tx">'+content+'<\/span>'; aw = document.getElementById("tx").offsetWidth; lefttime=setInterval("scrollticker()",50);}} function scrollticker(){mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";} window.onload=startticker;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles