Safari and class method replacement

Y

yavannadil

Hello!

I use the following to translate button names in Google Maps:

G_NORMAL_MAP.getName = function(short) {
if(short) {return "Karta"}
return "Karta";
}

It works (tested) with Firefox 1.5 (Linux and Mac) and Opera 9 (Mac).
But Safari 1.3. says "Parse error".
What is wrong - code or Safari?

Thanks,
Dmitri
 
R

Richard Cornford

I use the following to translate button names in Google Maps:

G_NORMAL_MAP.getName = function(short) {
if(short) {return "Karta"}
return "Karta";
}

It works (tested) with Firefox 1.5 (Linux and Mac) and
Opera 9 (Mac). But Safari 1.3. says "Parse error".
What is wrong - code or Safari?

I don't have a copy of Safari to test with (and cannot be bothered to
load Knoppix to see if Konqueror has the same issue), but if automatic
semicolon insertion was not properly implemented in Safari then the
absence of a semicolon at the end of the first return statement may be
the problem. That can be tested by replacing:-

if(short) {return "Karta"}

- with:-

if(short) {return "Karta";}

- or:-

if(short) {
return "Karta"
}

The missing semicolon should be inserted as the 'offending token' is },
but maybe it hasn't been in Safari.

Richard.
 
Y

yavannadil

Richard Cornford пиÑал(а):
I don't have a copy of Safari to test with (and cannot be bothered to
load Knoppix to see if Konqueror has the same issue), but if automatic
semicolon insertion was not properly implemented in Safari then the
absence of a semicolon at the end of the first return statement may be
the problem.

Thank you for advice, but apparently problem is not with semicolon
(i.e. I added it, it didn't help)

Safari insists that "Syntax Error - Parse Error" is on the following
line:

G_NORMAL_MAP.getName = function(short) {
 
Y

yavannadil

Julian Turner пиÑал(а):
Try a different Identifier name for the function argument.

Thanks! That was it.
You saved me from implementing custom map control :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top