Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts

    script works on .html but not .shtml

    Hello,

    I have a News Ticker script that works fine on one website (.html) but does not on my new website (.shtml)

    I am not sure why and whether the issue is the different extensions or whether it is different DOC TYPES. I did change the HTML to SHTML is the below but didn't make any difference.

    This is the code that works on my .html page:


    HEAD
    PHP Code:
    <SCRIPT LANGUAGE="JavaScript">
    var 
    newslist=new Array();
    var 
    cnt=0;            // current news item
    var curr "";
    var 
    i=-1;            // current letter being typed

    newslist[0]=new Array("The Legoland Times has moved home! Please visit our new home at www.minifigtimes.com","http://www.minifigtimes.com")
    newslist[1]=new Array("Happy building! :)","http://www.minifigtimes.com")

    function 
    newsticker()
    {
      
    // next character of current item
      
    if (newslist[cnt][0].length 1)
      {
        
    i++;
        
    temp1 newslist[cnt][0];
        
    temp1 temp1.split('');
        
    curr curr+temp1[i];
        
    temp2 newslist[cnt][1];
        
    mtxt.innerHTML "<a href='"+temp2+"'>"+curr+" _</a>";
        
    setTimeout('newsticker()',35)
        return;
      }
      
    // new item
      
    = -1curr "";
      if (
    cnt<newslist.length-1)
        
    cnt++;
      else
        
    cnt=0;
      
    setTimeout('newsticker()',6500)
    }
    </script>

    </HEAD> 
    BODY
    PHP Code:

    <BODY onLoad="newsticker()">


    <
    span id="mtxt" style="position:relative;top:1px;padding:5px 5px 5px 5px;font-family:arial;font-size:10pt;width:100%;overflow:auto;height:75px">
    </
    span
    I have set up a test page here: http://www.minifigtimes.com/index6.shtml

    This is the page where it is working: http://legolandtimes.bravehost.com/


    One other thing I want to do is be able to call a class for the text size / font etc. How do I do this ? I want to remove font-family:arial;font-size:10pt; or
    as many of these kind of attributes and replace with CSS.

    Any help much appreciated! thanks

  • #2
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Anyone have any ideas?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    A page which works correctly as .html will also work in the same manner as .shtml. There is nothing different about .shtml. Are you quite sure that your ISP supports .shtml and server-side includes?

    Try adding the following to your .shtml page and see what you get:-

    <B> The Local Time is
    <!--#echo var="DATE_LOCAL" -->
    </B>


    Quizmaster: In seafood on a restaurant menu, the French word "poisson" translates into English as what?
    Contestant: Chicken

  • #4
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Try adding the following to your .shtml page and see what you get:-

    <B> The Local Time is
    <!--#echo var="DATE_LOCAL" -->
    </B>

    Yes that works fine, I get my local time

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    In that case I am stumped - I can see no reason at all why your page should not work as .shtml.

    What exactly do you mean by "it does not work on my new website". It does not work at all or works incorrectly in some way?

    What error messages do you get?
    Have you tried putting in alerts at strategic positions in the script to check progress?
    And are you 100% absolutely sure that the .shtml is 100% identical with the .html code with no "copy and paste" slip-up? e.g. missing </script> tag?

    As a completely wild throw, try changing the deprecated

    <SCRIPT LANGUAGE="JavaScript">

    to

    <script type = "text/javascript">

  • Users who have thanked Philip M for this post:

    Partizan (05-13-2009)

  • #6
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thanks for your help..

    I have done the following test.. i copied the exact page on my old site to a new page index5.shtml and it works fine..

    I must be missing some code or maybe there is some conflict with another script or something.. I am trying to see what I have done wrong!

  • #7
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Seemingly the problem is this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">


    It nearly works 100% correct before if I delete the above DOCTYPE... as shown here http://www.minifigtimes.com/index6.shtml the first time the news ticker writes a line the first 10 or so characters are missing. Instead of reading "The Legoland Times has moved home! Please visit our new home at www.minifigtimes.com" it reads "oved home! Please visit our new home at www.minifigtimes.com"

    I tried replacing the deleted DOCTYPE above with
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    as this is used on the old site (automatically generated I see after I click View Source)
    Last edited by Partizan; 05-13-2009 at 12:19 PM.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    The script works fine for me (in IE) when run locally with either DOCTYPE.

    Try introducing a short delay (say 500ms) before calling newsticker()
    Last edited by Philip M; 05-13-2009 at 12:45 PM.

  • Users who have thanked Philip M for this post:

    Partizan (05-13-2009)

  • #9
    Regular Coder Partizan's Avatar
    Join Date
    Dec 2008
    Location
    Legoland and Ireland
    Posts
    139
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Not sure how to do that but it is a good idea.

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Code:
    <BODY onload="delayNewsticker()"> 
    
    <script type = "text/javascript">
    function delayNewsticker() {
    setTimeout('newsticker()',500);  // 500 milliseconds delay
    }
    
    </script>
    No guarantee that this works! I am afraid that I still see no reason for your problem, but I doubt if DOCTYPE has anything to do with it. Not do I recall seeing a similar problem before, i.e. the first time the news ticker writes a line the first 10 or so characters are missing.


  •  

    Posting Permissions

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