Question posted by: TS
(Guest)
on
July 20th, 2005 12:49 PM
Does anyone know if the Mac Browsers (IE5 / Safari) support anonymous
functions or lambda functions? Ive been trying to get a site working
with the Mac browsers and just cant get it to work. Here is an example
of what Im trying to do:
function CSelect(sName, id, bmpReqRO, minOptions, onvalid, isAddr,
sLabel){
this.obj = document.getElementById(id);
this.focus = m_focus;
this.blur = m_blur;
this.disable = m_disable;
this.enable = m_enable;
//alert(sName);
var slct = makeProps(this, bmpReqRO, id);
//alert(slct.required);
if (navigator.appVersion.indexOf("Mac") > -1)
{
slct.options = slct.obj.options;
}
else
{
slct.options = obj.options;
}
slct.label = sLabel;
slct.minOptions = minOptions;
slct.type = "Select";
if(onvalid)
slct.onvalid = new Function(onvalid);
slct.getValue = function slct_getValue(){
return slct.obj.value
}
if(slct.readOnly){
slct.disable();
}
//if(slct.obj.getAttribute("OnSelect")){
//slct.obj.onchangeFunc = slct.obj.onchange;
//slct.obj.onchange = new Function("onItemSelect(this)");
//}
if (navigator.appVersion.indexOf("Mac") > -1)
{
if(slct.obj.getAttribute("OnSelect")){
obj.onchangeFunc = slct.obj.onchange;
// THIS LINE DOES NOT WORK WITH THE MAC
obj.onchange = new Function("onItemSelect(this)");
}
}
else
{
if(slct.obj.getAttribute("OnSelect")){
slct.obj.onchangeFunc = slct.obj.onchange;
slct.obj.onchange = new Function("onItemSelect(this)");
}
}
.. . . Continued . . .
function onItemSelect(oSelect){
var oSelected = oSelect[oSelect.selectedIndex];
var onselect = oSelected.getAttribute("onSelect");
if(oSelect.onChangeFunc)
oSelect.onChangeFunc();
if(onselect){
var oSelectedFunc = new Function(onselect);
oSelectedFunc();
}
}
|
|
July 20th, 2005 01:01 PM
# 2
|
Re: Anonymous Functions / Mac Browser
TS wrote:
[color=blue]
> Does anyone know if the Mac Browsers (IE5 / Safari) support anonymous
> functions or lambda functions? Ive been trying to get a site working
> with the Mac browsers and just cant get it to work. Here is an example
> of what Im trying to do:
>
> [...]
> if (navigator.appVersion.indexOf("Mac") > -1)[/color]
Nonsense. Read <http://pointedears.de.vu/scripts/test/whatami>
[color=blue]
> {
> if(slct.obj.getAttribute("OnSelect")){[/color]
Do not use getAttribute(...) but, because of flawed implementations,
access the property directly. Besides, I doubt that there is a
`OnSelect' property in the DOM. J(ava)Script ist case-sensitive, it
is most certainly `onselect'. And you should test then if the property
type is not undefined and the value is not null.
[color=blue]
> obj.onchangeFunc = slct.obj.onchange;
> // THIS LINE DOES NOT WORK WITH THE MAC[/color]
"Does not work" is a useless error description. [psf 4.11]
Please read <3FDBC2B2.1020908@PointedEars.de>
[color=blue]
> obj.onchange = new Function("onItemSelect(this)");[/color]
If it is really the line that triggers the error it could also mean
that you cannot overwrite the `onchange' property in the used DOM.
Since you did not post the error message (see above), one can only guess.
PointedEars
--[color=blue]
> does anyone have any info about how can i make an explorer type menu?[/color]
Care to be more specific? Windows Explorer? Internet Explorer? Jungle
Explorer? (Fabian in cljs, <brk1e1$46tab$1@ID-174912.news.uni-berlin.de>)
|
|
July 20th, 2005 01:01 PM
# 3
|
Re: Anonymous Functions / Mac Browser
In article <3FE4E762.7040706@PointedEars.de>, Thomas 'PointedEars' Lahn
<PointedEars@web.de> writes:
[color=blue]
>Please read <3FDBC2B2.1020908@PointedEars.de>[/color]
Please use URL's to articles that anyone can gain access to. That does nothing
for me.
--
Randy
|
|
July 20th, 2005 01:02 PM
# 5
|
Re: Anonymous Functions / Mac Browser
T S wrote:
[color=blue]
> I guess you kind of missed the point of my post.[/color]
Well, you made it not difficult to miss it.
[color=blue]
> I really just wanted to know if the Mac browser supported anonymous /
> lambda functions.[/color]
A simple test case will show that. No question here is necessary.
var x;
x = new Function("var y = 2;");
alert(x); // undefined?
[color=blue]
> I do not get an error message at all,[/color]
Then why do you ask? Either the Function constructor is supported or
it is not. If the latter, the mentioned line should either (better)
trigger a script error or the value of the property the return value
of the `new' operation is assigned to does not change.
[color=blue]
> it just doesnt seem to recognize them.[/color]
There can be numerous possibilities why the mentioned line does not
work. Maybe the event handler `onchange' it is not part of the DOM
and you have added merely a method being only manually invoked.
Debugging will show this, follow the message ID that I have posted.
[color=blue]
> You are right about the OnSelect not being part of the DOM, it is an
> anonymous function of select object we created ourselves.[/color]
You missed the point. JavaScript ist *case-sensitive*. There may
be `onselect', but it is unlikely that there is `OnSelect'.
PointedEars
|
|
July 20th, 2005 01:03 PM
# 7
|
Re: Anonymous Functions / Mac Browser
> Thanks for the response. I tried out your suggestion with the test[color=blue]
> function and it seemed to work fine on MAC IE and Safari. So I guess
> that answers my question about anonymous functions. I still get no
> Javascript error when it processes, I just don't get the desired
> results. I would love to be able to step through a debugger on this but
> as far as I know one doesn't exist for MAC IE5 or Safari. Unfortunately
> this all works really well on Windows IE so I can't debug it over there.
> I tried the onselect change as well with no luck. I will continue to
> look into and post any info as I gather it. Thanks again.[/color]
My experience with IE Mac suggests that Microsoft did not put its smartest guys
on the Mac team. It is considerably bugger than the Windows browser. It has race
bugs. It will fail silently, or quit with a meaningless error message. It is
bad, bad stuff.