...

View Full Version : script works on .html but not .shtml



Partizan
05-07-2009, 10:34 AM
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


<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 (i < 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
i = -1; curr = "";
if (cnt<newslist.length-1)
cnt++;
else
cnt=0;
setTimeout('newsticker()',6500)
}
</script>

</HEAD>



BODY



<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

Partizan
05-13-2009, 11:40 AM
Anyone have any ideas? :confused:

Philip M
05-13-2009, 12:00 PM
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

Partizan
05-13-2009, 12:09 PM
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 :)

Philip M
05-13-2009, 12:28 PM
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">

Partizan
05-13-2009, 12:59 PM
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!

Partizan
05-13-2009, 01:07 PM
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)

Philip M
05-13-2009, 01:43 PM
The script works fine for me (in IE) when run locally with either DOCTYPE.

Try introducing a short delay (say 500ms) before calling newsticker()

Partizan
05-13-2009, 02:22 PM
Not sure how to do that but it is a good idea.

Philip M
05-13-2009, 04:29 PM
<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum