does this way to start a function not work with NS?

D

Dave

Hi,

This way to start a function works with IE; why doesn't it work with NS (7).

<input type="button" id="test">
<script>
function test.onclick()
{
....
}
</script>

thanks
dave
 
L

Lasse Reichstein Nielsen

Dave said:
This way to start a function works with IE; why doesn't it work with NS (7).

Why should it?

Because Mozilla (which Netscape 7 is based on) follows the ECMAScript
standard for syntax, and what you have written isn't correct.
<input type="button" id="test">
<script>

function test.onclick()

You can only write an identifier as a function name:
function testOnclick(){

You can then assign that to test.onclick either with a later
test.onclick = testOnclick
or directly with an anonymous function
test.onclick = function () {

/L
 
D

Douglas Crockford

This way to start a function works with IE; why doesn't it work with NS (7).
<input type="button" id="test">
<script>
function test.onclick()
{
...
}
</script>

That form of function is not standard ECMAScript. It is a Microsoft extension.
If you want to run on other platforms, shun the Microsoft extensions.

Try this instead:

test.onclick = function (e) {
e = e || event;
...
};

http://www.crockford.com
 

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,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top