View Full Version : JS fine on PC, but not MAC.... ahhh
game_on
Apr 11, 2004, 06:43 PM
Please please can anyone shed some light on why this is fine on my PC, but not on my client's mac.... (OS9 and OSX)
http://www.3ainteractive.com/temp/mactest.cfm
Its is just a simple script to move something from one column to another...
Please advise...
M@)
Benjamin
Apr 11, 2004, 06:48 PM
works in safari... they move back and forth.
TEG
Apr 11, 2004, 06:50 PM
Works fine for me in OSX-Safari. I don't have any OS9 Browsers to try, but I believe the problem is with your client's machine. Maybe they have an older Browser with out the right JavaScript (No Relation to Java™). Have them update their Safari, or Mozilla Builds to the newest ones available.
TEG
Blackheart
Apr 11, 2004, 07:02 PM
For me, it works on Safari (version 1.2.1), Firefox (version .8/ Mozilla 5.0) but will not work on IE (version 5.2).
HexMonkey
Apr 11, 2004, 07:02 PM
I've just tested it in 9 browsers on Mac OS X. Here's the results:
Works perfectly in Safari 1.2.1, Netscape 7.1, Firefox 0.8, Mozilla 1.4, Omniweb 3.5 and TrailBlazer 0.5.
Script works in iCab 2.9.7, but it's not displayed properly.
Script works in Opera 6.02, but the columns are not redrawn (eg an item does actually move, but the user can't see that this has happened).
Script doesn't work in IE 5.2.3.
I'd suggest validating the site at http://validator.w3.org/. Sites that validate are generally much more consistent between browsers and usually display as expected.
Westside guy
Apr 11, 2004, 07:12 PM
It's probably worth noting that Internet Explorer on the Mac hasn't been developed for a couple years - so any fixes Microsoft has put into their Windows browser have not made it to the Mac version (and won't, ever).
game_on
Apr 12, 2004, 06:52 AM
Hi, cheers everyone. I have used that validator - great stuff. Does it work in IE MAc now?
M@)
HexMonkey
Apr 12, 2004, 07:38 AM
No it still doesn't. I did I bit of debugging and found that the line 'index.push(i);' is the culprit. I did some quick research and apparently IE for Mac has a version of Javascript that is too old to use this method. You may have to find some alternative code.
game_on
Apr 12, 2004, 09:17 AM
This 'should' now work on MAC ie as a result of:
if (![].push) Array.prototype.push = ArrayPush;
function ArrayPush()
{
this[this.length] = arguments[0];
return(this.length);
}
Does it?
HexMonkey
Apr 12, 2004, 07:05 PM
No, but if you replace 'index.push(i)' with 'index[index.length]=i' it does. However, the new code no longer works in Netscape, Mozilla, Firefox, Opera and iCab (and probably Camino). It deleted an item from the list, but doesn't add it to the new one. :confused:
game_on
Apr 12, 2004, 07:15 PM
Hi HexMonkey, thanks for the advice, and thank you for helping a mac less person.
I have adjusted the code to:
<script type="text/javascript" language="JavaScript">
function moveOption(sourceSelect, targetSelect)
{
var index = new Array();
for (var i = 0; i < sourceSelect.options.length; i++) {
if (sourceSelect.options[i].selected)
index[index.length]=i;
}
if (index.length == 0) {
alert("Please select at least one item to move");
return;
}
while(index.length != 0) {
var i = index.pop();
var option = sourceSelect.options[i];
var temp = new Option(option.text, option.value);
sourceSelect.options[i] = null;
targetSelect.add(temp);
}
}
</script>
Do it work in MAC IE now?
http://www.3ainteractive.com/temp/mactest2.cfm
M@)
HexMonkey
Apr 12, 2004, 07:30 PM
I discovered that it wasn't the pop code that was causing the problem in Firefox, Netscape etc, it was something else (I'm not sure what). But by modifying the original file (which I had saved to disk), I got the script working in all my browsers (except the display problems in iCab and Opera which were always there). Here is the page's code in its entirity:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="JavaScript">
if (![].pop) Array.prototype.pop = ArrayPop;
function ArrayPop()
{
var tempItem = this[this.length-1];
this.length--;
return(tempItem);
}
function moveOption(sourceSelect, targetSelect)
{
var index = new Array()
for (var i = 0; i < sourceSelect.options.length; i++)
{
if (sourceSelect.options[i].selected)
{
index[index.length]=i;
}
}
if (index.length == 0)
{
alert("Please select at least one item to move");
return;
}
while(index.length != 0)
{
var i = index.pop();
var option = sourceSelect.options[i]
var temp = new Option(option.text, option.value)
sourceSelect.options[i] = null
targetSelect.options[targetSelect.options.length] = temp
}
}
function SelectAllOf(){
s=document.AssignPlayer.TeamPlayerList;
for(var i=0;i<s.options.length;i++){
s.options[i].selected=true;
}
t=document.AssignPlayer.AvPlayerList;
for(var i=0;i<t.options.length;i++){
t.options[i].selected=true;
}
}
function ClearThem(){
s=document.AssignPlayer.TeamPlayerList;
for(var i=0;i<s.options.length;i++){
s.options[i] = null;
}
t=document.AssignPlayer.AvPlayerList;
for(var i=0;i<t.options.length;i++){
t.options[i] = null;
}
}
function setStyle(obj,style,value){
getRef(obj).style[style]= value;
}
function getRef(obj){
return (typeof obj == "string") ?
document.getElementById(obj) : obj;
}
</script>
</head>
<body>
Trying to get this worhking on Mozilla/4.0 (compatible; MSIE 5.16; Mac_PowerPC).<br> <br>
It does not work on Does not work on IE 5.2. I am trying to find out what I could change in the JS to make it work?<br> <br>
<form name="AssignPlayer" action="post">
<table width="50" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<input tabindex="5" name="backtolib" type="button" onclick="moveOption(document.AssignPlayer.TeamPlayerList, document.AssignPlayer.AvPlayerList)" value="REMOVE PLAYERS >>" class="button" style="width:270px;"><br>
<select name="TeamPlayerList" class="form_input" size="2" multiple style="width:270px;">
<option value="1">One</option>
</select>
<input tabindex="7" name="backtolib" type="button" onclick="moveOption(document.AssignPlayer.TeamPlayerList, document.AssignPlayer.AvPlayerList)" value="REMOVE PLAYERS >>" class="button" style="width:270px;">
</td>
<td>
<input tabindex="6" name="addtot" type="button" onclick="moveOption(document.AssignPlayer.AvPlayerList, document.AssignPlayer.TeamPlayerList);" value="<< ADD PLAYERS" class="button" style="width:270px;"><br>
<select name="AvPlayerList" class="form_input" size="2" multiple style="width:270px">
<option value="2">Two</option>
</select>
<input tabindex="8" name="addtot" type="button" onclick="moveOption(document.AssignPlayer.AvPlayerList, document.AssignPlayer.TeamPlayerList);" value="<< ADD PLAYERS" class="button" style="width:270px;">
</td>
</tr>
</table>
</form>
</body>
</html>
game_on
Apr 12, 2004, 07:38 PM
Oh my god... That's sooo cool! Its been so hard to get this mac tested when I do not have one....
It definately works in IE5.2 on your MAC (OX9 and OSX)?
http://www.3ainteractive.com/temp/mactest3.cfm
You are a god!
M@
HexMonkey
Apr 12, 2004, 07:59 PM
It definately works in IE5.2 on your MAC (OX9 and OSX)?
Yes, the script works in IE 5.2.3 for Mac OS X, IE 5.0 for Mac OS 9, and 9 other OS X browsers (including Camino, which I just downloaded).
game_on
Apr 12, 2004, 08:02 PM
Hail HexMonkey!!
Message for you.
436865657273206D6174652E20205468616E6B20796F7520736F6F206D7563682E2020596F7520617265206163652100
HexMonkey
Apr 12, 2004, 08:13 PM
Thanks, got the message (thanks to a script I wrote three years ago). :)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.