# Help - JavaScript OK in Firefox but not in Safari/Dashboard



## jimmac (Sep 4, 2005)

I'm trying to learn enough JavaScript to build a simple widget. The widget will load an external web page into an iframe and reload the page the next day upon Dashboard activation. I thought I was getting close but have found that my code will run OK in Firefox but not in Safari (and not under Dashboard). I'm hoping if I can get it to run in Safari it will run as a widget.

Following is some testing code that loads a page into an iframe that displays the current time and reloads the page when the button is clicked. As written below, the page will be reloaded upon clicking the button if a new second is reached time-wise. (The button will not be used in the widget and the function will changed to check for a new day instead of a new second.)

The reload does not occur with a button onclick in Safari but works fine in Firefox. Can anyone help me get this to run in Safari? (Please be _really_ specific as I'm new to this.)

My environment:
OS X 10.4.2
Safari 2.0.1 (yes, JavaScript is enabled!)
Firefox 1.0.6

Thanks!

(Remove the first and last line comment/uncomment tags.)

<!--
<!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=iso-8859-1">
    <title>NISTdebug</title>
    <script language="JavaScript" type="text/JavaScript">
	<!--HIDE
var storedate
function onshow() {
	var now = new Date();
	nowString = new String(now);
	var slength = nowString.length;
	var nowdate;
	if (slength == 33) {
		var nowdate = nowString.substring(0,25);
		//nowdate will eventually be redefined to allow reload of iframe only with new day)
	}
	else {
		nowdate = nowString.substring(0,24);
	}
	if (storedate != nowdate) {
		storedate = nowdate;
		document.getElementById("NISTframe").src="http://nist.time.gov/timezone.cgi?Central/d/-6";
	}
}
	//STOP HIDING-->
</script>
</head>
<body>
    <button type="button" name="Run_onshow" onclick="onshow()">Run onshow function</button>
    <iframe src="http://nist.time.gov/timezone.cgi?Central/d/-6" id="NISTframe" width="480" height="340" scrolling="no" style="position: absolute; top: 40px; left: 0px;" name="NISTframe"></iframe>
</body>
</html>
-->


----------



## ElDiabloConCaca (Sep 4, 2005)

Try changing *onclick="onshow()"* to *onclick="javascriptnshow();"*

Just a wild guess.


----------



## jimmac (Sep 4, 2005)

ElDiabloConCaca said:
			
		

> Try changing *onclick="onshow()"* to *onclick="javascriptnshow();"*
> 
> Just a wild guess.


Thanks for the suggestion but the change results in no change: the .html code still works in Firefox but not in Safari.

-----

jimmac
Macintosh consulting for the Milwaukee, WI metro area
www.yourmacdoc.com


----------

