By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

Anonymous Functions / Mac Browser

P: n/a
TS
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();
}
}
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
TS wrote:
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)
Nonsense. Read <http://pointedears.de.vu/scripts/test/whatami>
{
if(slct.obj.getAttribute("OnSelect")){
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.
obj.onchangeFunc = slct.obj.onchange;
// THIS LINE DOES NOT WORK WITH THE MAC
"Does not work" is a useless error description. [psf 4.11]

Please read <3F**************@PointedEars.de>
obj.onchange = new Function("onItemSelect(this)");
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
-- does anyone have any info about how can i make an explorer type menu?

Care to be more specific? Windows Explorer? Internet Explorer? Jungle
Explorer? (Fabian in cljs, <br************@ID-174912.news.uni-berlin.de>)
Jul 20 '05 #2

P: n/a
In article <3F**************@PointedEars.de>, Thomas 'PointedEars' Lahn
<Po*********@web.de> writes:
Please read <3F**************@PointedEars.de>


Please use URL's to articles that anyone can gain access to. That does nothing
for me.
--
Randy
Jul 20 '05 #3

P: n/a
T S
I guess you kind of missed the point of my post. I really just wanted to
know if the Mac browser supported anonymous / lambda functions. I do not
get an error message at all, it just doesnt seem to recognize them. You
are right about the OnSelect not being part of the DOM, it is an
anonymous function of select object we created ourselves. It was
difficult to post all of the code.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

P: n/a
T S wrote:
I guess you kind of missed the point of my post.
Well, you made it not difficult to miss it.
I really just wanted to know if the Mac browser supported anonymous /
lambda functions.
A simple test case will show that. No question here is necessary.

var x;
x = new Function("var y = 2;");
alert(x); // undefined?
I do not get an error message at all,
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.
it just doesnt seem to recognize them.
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.
You are right about the OnSelect not being part of the DOM, it is an
anonymous function of select object we created ourselves.


You missed the point. JavaScript ist *case-sensitive*. There may
be `onselect', but it is unlikely that there is `OnSelect'.
PointedEars
Jul 20 '05 #5

P: n/a
T S


Thanks for the response. I tried out your suggestion with the test
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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #6

P: n/a
> Thanks for the response. I tried out your suggestion with the test
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.


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.

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.