• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 'do JavaScript' still broken in Safari 3 beta
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'do JavaScript' still broken in Safari 3 beta


  • Subject: Re: 'do JavaScript' still broken in Safari 3 beta
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 21 Jun 2007 17:20:30 -0400

On 6/21/07, David Crowe <email@hidden> wrote:
I think whatever ECMA says about 'return' is meaningless for
Javascript because everything is essentially a function in web
programming with javascript.

Well, first of all, Javascript is a trade name for the language specified by the ECMA-262 specification, which is called "ECMAScript" in the specification itself. So by definition, whatever is in there applies to JavasScript. Whether or not a given Javascript implementation chooses to follow the standard is another matter.


For example, something like <p onclick='afunction()'> has to
implicitly return(true) in order for the browser to know that the
click worked. What if afunction doesn't return true or, worse yet,
returns false? Then you'd have to modify the code to <p
onclick='afunction();return true'> which means you have to consider
the entire onclick javascript string as a function with an implicit
wrapper.

They are, in fact, implemented as anonymous functions (a.k.a. closures). Putting this in your HTML:

<p id="myparagraph" onclick="afunction(); return true">

is exactly equivalent to having this code:

document.getElementById("myparagraph").onclick = function() {
afunction(); return true; }

So the "return" is within a FunctionBody, and therefore syntactically valid.

It's worth noting that, in general, the trend now is away from
embedding Javascript in HTML and toward non-intrusive means of
scripting pages.

--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: 'do JavaScript' still broken in Safari 3 beta
      • From: David B.Gustavson <email@hidden>
  • Prev by Date: Re: Amazon Web Services
  • Next by Date: Re: [Meta:] Re: Amazon Web Services
  • Previous by thread: Re: 'do JavaScript' still broken in Safari 3 beta
  • Next by thread: Re: 'do JavaScript' still broken in Safari 3 beta
  • Index(es):
    • Date
    • Thread