newseed
10-31-2006, 05:33 PM
I found this old script and have been trying to tweak it for what I want to use it for and I did managed to get it to work in IE and Opera. However, FireFox and Netscape seems to be in a disagreement with the script and so it doesn't work and I don't know why.
However, if I just use the javascript all by itself with no other coding, it works fine in FF and Netscape. Go figure.
So I am incline to believe that I have made a mistake somewhere that FF and Netscape regconizes as being an error(s) in the code but I have yet to find it.
Here's the HTML code with the script that does work in IE and Opera but not in FF and Netscape:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">---
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- #BeginEditable "docmeta" -->
<meta name="description" content="_your description goes here_" />
<meta name="keywords" content="_your,keywords,goes,here_" />
<meta name="author" content="SCR" />
<link rel="stylesheet" type="text/css" href="ga-style.css" media="screen" title="Golden Almond (screen)" />
<link rel="stylesheet" type="text/css" href="ga-print.css" media="print" />
<script type="text/javascript" language="JavaScript1.1">
<!--
function mm_jumpmenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<!-- Note: The above script is used for printing where in the html a statement of 'onclick' is used elsewhere but is not used on this particular page-->
<title>Golden Almond Health Food Store</title>
<!-- #EndEditable -->
</head>
<body onLoad="dspltip()"><div id="wrap">
<div id="header">
<img id="frontphoto" src="images/ga-banner.jpg" width="754" height="131" alt="" />
<p>Address: <strong>339 Racetrack Rd. NW - Fort Walton Beach, FL
32547</strong> Phone: <strong>850.863.5811</strong> Fax: <strong>850.863.5765</strong></p>
<p>Open Monday - Friday 9:00am to 6:00pm and Saturday 10:00am to 4:00pm</p>
</div>
<div id="avmenu">
<h2 class="hide">Menu:</h2>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about-us.htm">About Us</a></li>
<li><a href="coupons-specials.htm">Coupons & Specials</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Health Notes</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.htm">Contact Us</a></li>
</ul>
<div align="center">
<p class="print-hide2"><img border="0" src="_inlcudes/credit-cards.jpg" width="100" height="21"></p>
</div>
<div class="announce">
<div id="healthtips">
<h3><a href="health-tips.htm">Health Tips</a></h3>
<!-- Begin Random Tips Script -->
<Span Id="mtxt" style="padding:15px 10px 10px 0px;font-family:Arial;width:130px;overflow:auto;height:300px">
</Span>
</div>
<Script Language="JavaScript" Src="totdmsg.js">
</Script>
<Script Language="JavaScript">
cnt=0;
todmsg.sort(rndm)
function rndm(a,b){
return (Math.random()-Math.random())
}
function chgstatus(){
if (dspl1.checked)
dspl1.checked=false;
else
dspl1.checked=true;
}
function dspltip(){
mtxt.innerHTML=todmsg[0]
cntr.innerHTML="1/"+todmsg.length
}
function endf(){
if (!dspl1.checked)
window.returnValue=1
else
window.returnValue=0
window.close();
}
</Script>
<!-- End Random Tips Script -->
</div>
<div id="chamber">
<p>Members of <br><a href="http://www.fwbchamber.org/">The Greater<br>Fort Walton Beach<br>Chamber of Commerce</a>.</p>
</div>
</div>
<div id="extras">
<h3>More info:</h3>
<p>This is the third column, which can be used in many different ways. For
example, it can be used for comments, site news, ads, etc. It is all up to you!</p>
<h3>Our location:</h3>
<p>We are located in the Winrock Plaze Shopping Center on Racetrack Rd between
Mar Walt Dr and Denton Blvd. Click <a href="directions.htm">here</a> to get directions.</p>
<p class="small">Only you can make a healthy choice!</p>-->
</div>
<div id="content">
<!-- #BeginEditable "content" -->
<h2>Header here</h2>
<!-- #EndEditable -->
</div>
<div id="footer">
Copyright © 2006 Golden Almond.
</div>
</div>
</body>
</html>
Here's the JAVASCRIPT file:
bver=navigator.appVersion.split(";");
function totdstart(){
if(bver[1].match("5."))
rv=window.showModalDialog("tips-list.html",null,"dialogWidth:130px;dialogHeight:200px;center:1;scroll:0;help:0;status:0");
else
rv=window.showModalDialog("tips-list.html",null,"dialogWidth:130px;dialogHeight:200px;center:1;scroll:0;help:0");
nd= new Date();
nd.setTime (nd.getTime()+(365*24*60*60*1000));
cdomain = (location.domain) ? location.domain : null;
cpath = (location.domain) ? location.pathname : null;
if (rv!=0)
SetCookie ("tips-list", "true", nd, cpath, cdomain);
}
function totdinit(){
if (document.all){
if (GetCookie("tips-list")!="true")
totdstart()
else
document.body.insertAdjacentHTML('beforeEnd','<Div Id="etotd" style="width:140;position:absolute;top:0;left:0;BACKGROUND-COLOR:#B71717;BORDER-BOTTOM:#5C0000 solid 2px;BORDER-LEFT:#FE5E5E solid 2px;BORDER-RIGHT:#5C0000 solid 2px;BORDER-TOP:#FE5E5E solid 2px;font-family:Arial;font-size:8pt;font-weight:bold;text-align:center;padding-top:2px;padding-bottom:2px;color:#FFFFFF;cursor:default" onclick="enable()" onmouseover="mover()" onmouseout="mout()">Enable Tip of the Day</Div>');
}
}
function enable(){
DeleteCookie("tips-list");
etotd.innerHTML="Tip of the Day enabled";
setTimeout('etotd.style.visibility="hidden";totdstart()',1000);
}
function mover(){
etotd.style.borderLeftColor="#5C0000";
etotd.style.borderRightColor="#FE5E5E";
etotd.style.borderBottomColor="#FE5E5E";
etotd.style.borderTopColor="#5C0000";
etotd.style.paddingLeft="1px";
etotd.style.paddingTop="3px";
}
function mout(){
etotd.style.borderLeftColor="#FE5E5E";
etotd.style.borderRightColor="#5C0000";
etotd.style.borderBottomColor="#5C0000";
etotd.style.borderTopColor="#FE5E5E";
etotd.style.paddingLeft="0px";
etotd.style.paddingTop="2px";
}
// Cookie Functions - Second Helping (21-Jan-96)
// Written by: Bill Dortch, hIdaho Design <bdortch@netw.com>
// The following functions are released to the public domain.
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 4) ? argv[5] : false;
document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain));
}
function DeleteCookie(name){
exp=new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie ("name");
document.cookie = name + "=" + cval +"; expires=" + exp.toGMTString();
}
Here's data script that the HTML and JAVASCRIPT use to put it all together:
todmsg=new Array();
// Add below your tips (Do not edit anything above this line !!!!)
todmsg[0]="Tip Zero ?"
todmsg[1]="Tip One ?"
todmsg[2]="Tip Two ?"
todmsg[3]="Tip Three ?"
todmsg[4]="Tip Four ?"
todmsg[5]="Tip Five ?"
todmsg[6]="Tip Six ?"
todmsg[7]="Tip Seven"
todmsg[8]="<strong>Cut out the bad fat in your diet:<br><br></strong><i>I hear people talking about Trans Fats in our diets. What is Trans Fats?</i><br><br><A HREF=\"news://comp.lang.javascript\">Read more</A>"
I like to be able to use this script. However, if you know of a better script that will work for all browsers, please let me know.
Note: I am not a javascript programmer. I am merely just a guy that is willing to get his hands dirty to figure things out.
Thanks for you time.
However, if I just use the javascript all by itself with no other coding, it works fine in FF and Netscape. Go figure.
So I am incline to believe that I have made a mistake somewhere that FF and Netscape regconizes as being an error(s) in the code but I have yet to find it.
Here's the HTML code with the script that does work in IE and Opera but not in FF and Netscape:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">---
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- #BeginEditable "docmeta" -->
<meta name="description" content="_your description goes here_" />
<meta name="keywords" content="_your,keywords,goes,here_" />
<meta name="author" content="SCR" />
<link rel="stylesheet" type="text/css" href="ga-style.css" media="screen" title="Golden Almond (screen)" />
<link rel="stylesheet" type="text/css" href="ga-print.css" media="print" />
<script type="text/javascript" language="JavaScript1.1">
<!--
function mm_jumpmenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<!-- Note: The above script is used for printing where in the html a statement of 'onclick' is used elsewhere but is not used on this particular page-->
<title>Golden Almond Health Food Store</title>
<!-- #EndEditable -->
</head>
<body onLoad="dspltip()"><div id="wrap">
<div id="header">
<img id="frontphoto" src="images/ga-banner.jpg" width="754" height="131" alt="" />
<p>Address: <strong>339 Racetrack Rd. NW - Fort Walton Beach, FL
32547</strong> Phone: <strong>850.863.5811</strong> Fax: <strong>850.863.5765</strong></p>
<p>Open Monday - Friday 9:00am to 6:00pm and Saturday 10:00am to 4:00pm</p>
</div>
<div id="avmenu">
<h2 class="hide">Menu:</h2>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about-us.htm">About Us</a></li>
<li><a href="coupons-specials.htm">Coupons & Specials</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Health Notes</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.htm">Contact Us</a></li>
</ul>
<div align="center">
<p class="print-hide2"><img border="0" src="_inlcudes/credit-cards.jpg" width="100" height="21"></p>
</div>
<div class="announce">
<div id="healthtips">
<h3><a href="health-tips.htm">Health Tips</a></h3>
<!-- Begin Random Tips Script -->
<Span Id="mtxt" style="padding:15px 10px 10px 0px;font-family:Arial;width:130px;overflow:auto;height:300px">
</Span>
</div>
<Script Language="JavaScript" Src="totdmsg.js">
</Script>
<Script Language="JavaScript">
cnt=0;
todmsg.sort(rndm)
function rndm(a,b){
return (Math.random()-Math.random())
}
function chgstatus(){
if (dspl1.checked)
dspl1.checked=false;
else
dspl1.checked=true;
}
function dspltip(){
mtxt.innerHTML=todmsg[0]
cntr.innerHTML="1/"+todmsg.length
}
function endf(){
if (!dspl1.checked)
window.returnValue=1
else
window.returnValue=0
window.close();
}
</Script>
<!-- End Random Tips Script -->
</div>
<div id="chamber">
<p>Members of <br><a href="http://www.fwbchamber.org/">The Greater<br>Fort Walton Beach<br>Chamber of Commerce</a>.</p>
</div>
</div>
<div id="extras">
<h3>More info:</h3>
<p>This is the third column, which can be used in many different ways. For
example, it can be used for comments, site news, ads, etc. It is all up to you!</p>
<h3>Our location:</h3>
<p>We are located in the Winrock Plaze Shopping Center on Racetrack Rd between
Mar Walt Dr and Denton Blvd. Click <a href="directions.htm">here</a> to get directions.</p>
<p class="small">Only you can make a healthy choice!</p>-->
</div>
<div id="content">
<!-- #BeginEditable "content" -->
<h2>Header here</h2>
<!-- #EndEditable -->
</div>
<div id="footer">
Copyright © 2006 Golden Almond.
</div>
</div>
</body>
</html>
Here's the JAVASCRIPT file:
bver=navigator.appVersion.split(";");
function totdstart(){
if(bver[1].match("5."))
rv=window.showModalDialog("tips-list.html",null,"dialogWidth:130px;dialogHeight:200px;center:1;scroll:0;help:0;status:0");
else
rv=window.showModalDialog("tips-list.html",null,"dialogWidth:130px;dialogHeight:200px;center:1;scroll:0;help:0");
nd= new Date();
nd.setTime (nd.getTime()+(365*24*60*60*1000));
cdomain = (location.domain) ? location.domain : null;
cpath = (location.domain) ? location.pathname : null;
if (rv!=0)
SetCookie ("tips-list", "true", nd, cpath, cdomain);
}
function totdinit(){
if (document.all){
if (GetCookie("tips-list")!="true")
totdstart()
else
document.body.insertAdjacentHTML('beforeEnd','<Div Id="etotd" style="width:140;position:absolute;top:0;left:0;BACKGROUND-COLOR:#B71717;BORDER-BOTTOM:#5C0000 solid 2px;BORDER-LEFT:#FE5E5E solid 2px;BORDER-RIGHT:#5C0000 solid 2px;BORDER-TOP:#FE5E5E solid 2px;font-family:Arial;font-size:8pt;font-weight:bold;text-align:center;padding-top:2px;padding-bottom:2px;color:#FFFFFF;cursor:default" onclick="enable()" onmouseover="mover()" onmouseout="mout()">Enable Tip of the Day</Div>');
}
}
function enable(){
DeleteCookie("tips-list");
etotd.innerHTML="Tip of the Day enabled";
setTimeout('etotd.style.visibility="hidden";totdstart()',1000);
}
function mover(){
etotd.style.borderLeftColor="#5C0000";
etotd.style.borderRightColor="#FE5E5E";
etotd.style.borderBottomColor="#FE5E5E";
etotd.style.borderTopColor="#5C0000";
etotd.style.paddingLeft="1px";
etotd.style.paddingTop="3px";
}
function mout(){
etotd.style.borderLeftColor="#FE5E5E";
etotd.style.borderRightColor="#5C0000";
etotd.style.borderBottomColor="#5C0000";
etotd.style.borderTopColor="#FE5E5E";
etotd.style.paddingLeft="0px";
etotd.style.paddingTop="2px";
}
// Cookie Functions - Second Helping (21-Jan-96)
// Written by: Bill Dortch, hIdaho Design <bdortch@netw.com>
// The following functions are released to the public domain.
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 4) ? argv[5] : false;
document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain));
}
function DeleteCookie(name){
exp=new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie ("name");
document.cookie = name + "=" + cval +"; expires=" + exp.toGMTString();
}
Here's data script that the HTML and JAVASCRIPT use to put it all together:
todmsg=new Array();
// Add below your tips (Do not edit anything above this line !!!!)
todmsg[0]="Tip Zero ?"
todmsg[1]="Tip One ?"
todmsg[2]="Tip Two ?"
todmsg[3]="Tip Three ?"
todmsg[4]="Tip Four ?"
todmsg[5]="Tip Five ?"
todmsg[6]="Tip Six ?"
todmsg[7]="Tip Seven"
todmsg[8]="<strong>Cut out the bad fat in your diet:<br><br></strong><i>I hear people talking about Trans Fats in our diets. What is Trans Fats?</i><br><br><A HREF=\"news://comp.lang.javascript\">Read more</A>"
I like to be able to use this script. However, if you know of a better script that will work for all browsers, please let me know.
Note: I am not a javascript programmer. I am merely just a guy that is willing to get his hands dirty to figure things out.
Thanks for you time.