30 users online (1 members and 29 guests)  


  Results 1 to 3 of 3

Related

  1. how to stop javascript via another javascript    Forum: Javascript Forum
    Replies: 0
  2. Replies: 0
  3. Replies: 5
  4. Replies: 0
  5. Web Hosting Explained for Novice and Newbie    Forum: Web Hosting Forum
    Replies: 2
  1. #1
    RCDORRJR's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2013
    Posts
    3

    Smile NOVICE WITH QUESTION on JavaScript?

    The script I use works perfectly in IE9 but does not work in Firefox or Chrome... JavaScript is enabled in all the browsers. The following is the script in question... Is there some added script I need to order for it to function in Firefox & Chrome? Thank You!

    <script type="text/javascript">

    <!-- Begin

    var msg=new Array()
    msg[0]="<CENTER>We Grew Up climbing<br>in Trees...</CENTER>";
    msg[1]="<CENTER>...We eat bark for Dinner</CENTER>";
    msg[2]="<CENTER>Our teeth can grind <br>any stump...</CENTER>";
    msg[3]="<CENTER>...Your tree problems<br>have a solution <br>with The Tree People!</CENTER>";
    msg[4]="<CENTER>We use state of <br>the art machinery...</CENTER>";
    msg[5]="<CENTER>We're a phone call away<br>...410-975-9333</CENTER>";




    // set your first set of colors. Use as many or as few as you wish.
    var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff",
    "8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222ff", "1111ff", "0000ff")

    //set your second set of colors
    // *** must have exactly the same number of colors as the array above ***
    var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999",
    "ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000")

    //set the height of the display in pixels
    high=64;

    //set the width of the display in pixels
    wide=245;

    //set the pixel coordinates for the upper left hand corner of the display
    Xpos=100;
    Ypos=230;

    // move the display away from the edges of the background
    pad=15;

    // set the background color of the display
    bgcol="ffffff";

    //add a background image if you want.
    // *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
    cellbg="";

    // set the font
    fntFam="verdana,helvetica,arial";
    fntSize=14;

    // set how how many seconds you want the message to stay remain at totality.
    pause=2.5;


    // Do not edit these values below!!!

    icolor=0;
    mcolor=1;
    imsg=0;
    spWidth=wide-(2*pad);
    totality=false;
    glowing=true;
    var theMsg="";
    var cellcontent="";
    pause=pause*1000;
    if(cellbg.length>4){cellbg=" background="+cellbg}
    else{cellbg="";}

    function doPause(){
    totality=false; t=setTimeout("changecolor()",pause);
    }
    function initiate(){
    getContentColor();
    getMsg();
    getCellContent();
    if(document.all){
    msgbg.innerHTML=cellcontent;
    msgfade.innerHTML=theMsg;
    msgbg.style.posLeft=Xpos;
    msgbg.style.posTop=Ypos;
    msgfade.style.posLeft=Xpos+pad;
    msgfade.style.posTop=Ypos+pad;
    t=setTimeout("changecolor()",50);}
    if(document.layers){
    document.msgbg.document.write(cellcontent);
    document.msgbg.document.close();
    document.msgfade.document.write(theMsg);
    document.msgfade.document.close();
    document.msgbg.left=Xpos;
    document.msgbg.top=Ypos;
    document.msgfade.left=Xpos+pad;
    document.msgfade.top=Ypos+pad;
    t=setTimeout("changecolor()",100);}
    }
    function changecolor(){
    if(totality==true){doPause();}
    else{
    getMsg();
    getContentColor();
    if(document.all){
    msgfade.innerHTML=theMsg;
    t=setTimeout("changecolor()",50);}
    if(document.layers){
    document.msgfade.document.write(theMsg);
    document.msgfade.document.close();
    t=setTimeout("changecolor()",70);}
    }
    }
    function getFadeColor(){
    icolor=icolor-1;
    if(mcolor==1){contentcolor=colors1[icolor];}
    else{contentcolor=colors2[icolor];}
    }
    function getGlowColor(){
    icolor=icolor+1;
    if(mcolor==1){contentcolor=colors1[icolor];}
    else{contentcolor=colors2[icolor];}
    }
    function changemsg(){
    if(imsg==msg.length-1){imsg=0; mcolor=1;}
    else if(imsg != msg.lenght-1 && mcolor==1){imsg=imsg+1; mcolor=0;}
    else{imsg=imsg+1; mcolor=1;}
    }
    function getContentColor(){
    if(icolor==colors1.length-1 && glowing==true){
    getFadeColor(); glowing=false; totality=true;}
    else if(icolor < colors1.length && glowing==true){
    getGlowColor();}
    else if(icolor < 1 && glowing==false){changemsg(); getGlowColor(); glowing=true;}
    else{getFadeColor();}
    }
    function getMsg() {
    theMsg="<span style='font-size:"+fntSize+"pt; font-family:"+fntFam+"; width:"+spWidth+";'>"
    theMsg+="<B><font color="+contentcolor+">"+msg[imsg]+"</font></B> "
    theMsg+="</span>"
    }
    function getCellContent(){
    cellcontent="<TABLE height="+high+
    " width="+wide+" bgcolor="+bgcol+" cellpadding=0 cellspacing=0><TR><TD"+cellbg+"> </TD></TR></TABLE>"}
    // End -->
    </script>

  2. #2
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: NOVICE WITH QUESTION on JavaScript?

    Hi there RCDORRJR ,

    and a warm welcome to these forums.

    You did not supply the HTML to go with the script, so I had to improvise....

    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title></title>
    
    <script type="text/javascript">
    
    var msgbg,msgfade;
    var msg=new Array();
        msg[0]="<center>We Grew Up climbing<br>in Trees...<\/center>";
        msg[1]="<center>...We eat bark for Dinner<\/center>";
        msg[2]="<center>Our teeth can grind <br>any stump...<\/center>";
        msg[3]="<center>...Your tree problems<br>have a solution <br>with The Tree People!<\/center>";
        msg[4]="<center>We use state of <br>the art machinery...<\/center>";
        msg[5]="<center>We're a phone call away<br>...410-975-9333<\/center>";
    
    // set your first set of colors. Use as many or as few as you wish.
       var colors1=new Array("ffffff","eeeeff","ddddff","ccccff","bbbbff","aaaaff","9999ff","8888ff",
                             "7777ff","6666ff","5555ff","4444ff","3333ff","2222ff","1111ff","0000ff")
    
    //set your second set of colors
    // *** must have exactly the same number of colors as the array above ***
       var colors2=new Array("ffffff","ffeeee","ffdddd","ffcccc","ffbbbb","ffaaaa","ff9999","ff8888",
                             "ff7777","ff6666","ff5555","ff4444","ff3333","ff2222","ff1111","ff0000")
    //set the height of the display in pixels
       high=64;
    //set the width of the display in pixels
       wide=245;
    //set the pixel coordinates for the upper left hand corner of the display
       Xpos=100;
       Ypos=230;
    // move the display away from the edges of the background
       pad=15;
    // set the background color of the display
       bgcol="ffffff";
    //add a background image if you want.
    // *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
       cellbg="";
    // set the font
       fntFam="verdana,helvetica,arial";
       fntSize=14;
    
    // set how how many seconds you want the message to stay remain at totality.
       pause=2.5;
    // Do not edit these values below!!!
       icolor=0;
       mcolor=1;
       imsg=0;
       spWidth=wide-(2*pad);
       totality=false;
       glowing=true;
       var theMsg="";
       var cellcontent="";
       pause=pause*1000;
    if(cellbg.length>4){
       cellbg=" background="+cellbg;
     }
    else{
       cellbg="";
     }
    
    function doPause(){
       totality=false; 
       t=setTimeout("changecolor()",pause);
     }
    function initiate(){
       msgbg=document.getElementById('msgbg');
       msgfade=document.getElementById('msgfade');
       getContentColor();
       getMsg();
       getCellContent();
       msgbg.innerHTML=cellcontent;
       msgfade.innerHTML=theMsg;
       msgfade.style.posLeft=Xpos;
       msgbg.style.posTop=Ypos+'px';
       msgfade.style.posLeft=Xpos+pad+'px';
       msgfade.style.posTop=Ypos+pad+'px';
       t=setTimeout("changecolor()",50);
     }
    function changecolor(){
    if(totality==true){
       doPause();
     }
    else{
       getMsg();
       getContentColor();
       msgfade.innerHTML=theMsg;
       t=setTimeout("changecolor()",50);
      }
     }
    function getFadeColor(){
       icolor=icolor-1;
    if(mcolor==1){
       contentcolor=colors1[icolor];
     }
    else{
       contentcolor=colors2[icolor];
      }
     }
    function getGlowColor(){
       icolor=icolor+1;
    if(mcolor==1){
       contentcolor=colors1[icolor];
     }
    else{
       contentcolor=colors2[icolor];
      }
     }
    function changemsg(){
    if(imsg==msg.length-1){
       imsg=0;
       mcolor=1;
     }
    else if(
       imsg!=msg.lenght-1&&mcolor==1){
       imsg=imsg+1; mcolor=0;
     }
    else{
       imsg=imsg+1; 
       mcolor=1;
      }
     }
    function getContentColor(){
    if(icolor==colors1.length-1&&glowing==true){
       getFadeColor(); 
       glowing=false; 
       totality=true;
     }
    else if(
       icolor<colors1.length&&glowing==true){
       getGlowColor();
     }
    else if(
       icolor<1&&glowing==false){
       changemsg(); 
       getGlowColor(); 
       glowing=true;
     }
    else{
       getFadeColor();
      }
     }
    function getMsg() {
       theMsg="<span style='font-size:"+fntSize+"pt; font-family:"+fntFam+"; width:"+spWidth+";'>";
       theMsg+="<b><font color="+contentcolor+">"+msg[imsg]+"<\/font><\/b>";
       theMsg+="<\/span>";
     }
    function getCellContent(){
       cellcontent="<table height="+high+" width="+wide+" bgcolor="+bgcol+
       " cellpadding=0 cellspacing=0><tr><td"+cellbg+"><\/td><\/tr><\/table>";
     }
       window.addEventListener?
       window.addEventListener('load',initiate,false):
       window.attachEvent('onload',initiate);
    
    </script> 
    
    </head>
    <body>
    
    <div id="msgbg"></div>
    <div id="msgfade"></div>
    
    </body>
    </html>
    
    ....but it does now work in other browsers.

  3. #3
    RCDORRJR's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2013
    Posts
    3

    Smile Re: NOVICE WITH QUESTION on JavaScript?

    Thank You... I will try it out soon and let you know how it worked out.