Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macs And Java 3

Status
Not open for further replies.

Bammy217

Programmer
Sep 28, 2002
74
BE
I have a small problem... is there anyone out there that is good with Macs (you know those designery things that no one really uses!)

as I have discovered that the ones we are encountering don't actually support some simpel java:

OnClick="document.location.href('somepage.html');"

doesn't actually work! (Ungh)

Any one have any hints??

We never fail, we just find that the path to succes is never quite what we thought...
 
The name is "Javascript". "Java" is something else.

Try
Code:
[red]onclick[/red]="document.location[red]=[/red]'somepage.html';"



--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Thanks for the warning, well the 'javascript' still doesn't seem to want to do it..

Unfortunately the spec requires me to use button inputs, so i'm stuck doing it this way, or i have to make all links on that page a get form...

Thou I do wonder does anyone out there in cyberland know what is up with these macs as none of the following seem to work on a default installed Mac OS X...

Code:
<a href="#" onclick="document.location='somepage.html';">Somepage</a>
Code:
<a href="#" onclick="document.location.href='somepage.html';">Somepage</a>
Code:
<input type="button" value="Somepage" onclick="document.location='somepage.html';">
Code:
<input type="button" value="Somepage" onclick="document.location.href='somepage.html';">
Code:
<input type="button" value="Somepage" onclick="document.location.href('somepage.html');">

I'm getting a bit desperate here, as no matter where i look, all references tell me that any of the above should work!

Well, any and all help would be appreciated!

cheers,
B.

We never fail, we just find that the path to succes is never quite what we thought...
 
How about
Code:
<a href="#" onclick="[red]window.location.replace('newpage.html'); return false;[/red]">New page</a>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Cheers, that worked!!

[peace] Thank you!

We never fail, we just find that the path to succes is never quite what we thought...
 
I'm also having a problem with JavaScript on Macs. What I'm trying to do here is copying the selected value from the first dropdown to the second one if Yes is clicked. It worked very well on PC browsers but not on Macs. Anyone happen to know why?

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function CopyDiet() {
document.form1.RecommendDiets.value = document.form1.Diets.value;
return false;
}
</SCRIPT>
</head>

<body>
<FORM NAME=form1>
<P>
Diets: <select name="Diets" size="1">
<option value="">
<option value="Advance as tolerated">Advance as tolerated
<option value="Clear liquids">Clear liquids
</select>

<P>
Continue Current Regimen:
<input type=radio name=ContinueCurrentRegimen value="Y"
onclick='CopyDiet(); '>Yes
<input type=radio name=ContinueCurrentRegimen value="N">No
</P>

<P>
Recommend Diets: <select name="RecommendDiets" size="1">
<option value="">
<option value="Advance as tolerated">Advance as tolerated
<option value="Clear liquids">Clear liquids

</select>
</P>
</FORM>
</body>
</html>
 
Change your function to this:

Code:
function CopyDiet() {
    var e = document.forms['form1'].elements;
    e['RecommendDiets'].selectedIndex = e['Diets'].selectedIndex;
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Actually, even better, change your entire page to this:

Code:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function CopyDiet() {
    var e = document.forms['form1'].elements;
	if ( e['ContinueCurrentRegimen'][0].checked )
	    e['RecommendDiets'].selectedIndex = e['Diets'].selectedIndex;
}
</SCRIPT>
</head>

<body>
<FORM NAME=form1>
<P>
Diets: <select name="Diets" size="1" onchange="CopyDiet();">
<option value="">
<option value="Advance as tolerated">Advance as tolerated
<option value="Clear liquids">Clear liquids
</select>

<P>
Continue Current Regimen:
<input type=radio name=ContinueCurrentRegimen value="Y"
onclick='CopyDiet();'>Yes
<input type=radio name=ContinueCurrentRegimen value="N">No
</P>

<P>
Recommend Diets: <select name="RecommendDiets" size="1">
<option value="">
<option value="Advance as tolerated">Advance as tolerated
<option value="Clear liquids">Clear liquids

</select>
</P>
</FORM>
</body>
</html>

This way, if you have "Yes" chosen, then when you change the first drop-down, the second one will change automatically.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
I'm having another problem with JavaScript on Mac Safari (it works on Mac IE though). There are two problems: 1. The timestamp displays year as 105 instead of 2005. 2. The calculation doesn't work, even after the year was corrected manually. Any ideas would be greatly appreciated.

function timestamp1(){
var now = new Date();
var theYear = now.getYear()
var theMon = now.getMonth()
var theDay = now.getDate()
var theHour = now.getHours()
var theMin = now.getMinutes()
var theTime = "" + (theMon + 1) + "/" + theDay + "/" + theYear + " " + ((theHour > 12) ? theHour - 12 : theHour)
theTime += ((theMin < 10)? ":0" : ":") + theMin
theTime += (theHour >= 12) ? " PM" : " AM"
document.form1.StartTime.value=theTime;
}

function timestamp2(){
var now = new Date();
var theYear = now.getYear()
var theMon = now.getMonth()
var theDay = now.getDate()
var theHour = now.getHours()
var theMin = now.getMinutes()
var theTime = "" + (theMon + 1) + "/" + theDay + "/" + theYear + " " + ((theHour > 12) ? theHour - 12 : theHour)
theTime += ((theMin < 10)? ":0" : ":") + theMin
theTime += (theHour >= 12) ? " PM" : " AM"
document.form1.EndTime.value=theTime;
}

<!-- Begin calculation time
function dateDiff1(form1) {

date1 = new Date();
date2 = new Date();
diff = new Date();

date1temp = new Date(document.form1.StartTime.value);
date1.setTime(date1temp.getTime());

date2temp = new Date(document.form1.EndTime.value);
date2.setTime(date2temp.getTime());

// sets difference date/time to difference of first date/time and second date/time

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));
timediff = diff.getTime();
mins = Math.floor(timediff / (1000 * 60));
document.form1.TimeSpent.value = mins;

return false; // form should never submit, returns false
}
// End -->
 
That worked! Thanks a lot. But the time interval calculation still doesn't work. It always gives me 0 no matter what the start time and end time are.
 
Rather than these lines:

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));
timediff = diff.getTime();
mins = Math.floor(timediff / (1000 * 60));

try:

timediff = Math.abs(date1.getTime() - date2.getTime());
mins = Math.floor(timediff / (1000 * 60));

Lee
 
Hmmm...still not working. The calculation results is always -0 on Mac Safari.
 
Try

var date1 = new Date(document.form1.StartTime.value);
var date2 = new Date(document.form1.EndTime.value);

alert(date1.getTime();
alert(date2.getTime();
timediff = Math.abs(date1.getTime() - date2.getTime());

This should give you an idea where the problem is. It skips the temporary date objects you were making, too, and that might be the problem.

Lee
 
trollacious meant to say:

Code:
var date1 = new Date(document.form1.StartTime.value);
var date2 = new Date(document.form1.EndTime.value);

alert(date1.getTime()[red])[/red];
alert(date2.getTime()[red])[/red];
timediff = Math.abs(date1.getTime() - date2.getTime());

*cLFlaVA
----------------------------
[tt]0101 is binary code for "supreme programmer of omnipotent power"[/tt] - adam0101
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top