Connecting Tech Pros Worldwide Forums | Help | Site Map

i'm doing something wrong with this function...

rwsims@gmail.com
Guest
 
Posts: n/a
#1: Feb 9 '06
This works in firefox, not at all in ie6. I'm not getting any errors,
but only the doalert() function works, not the click() function. I'm
sure there's something obvious, but I'm just not seeing it. Help would
be greatly appreciated.

--
Ryan W


rwsims@gmail.com
Guest
 
Posts: n/a
#2: Feb 9 '06

re: i'm doing something wrong with this function...


rws...@gmail.com wrote:[color=blue]
> This works in firefox, not at all in ie6. I'm not getting any errors,
> but only the doalert() function works, not the click() function. I'm
> sure there's something obvious, but I'm just not seeing it. Help would
> be greatly appreciated.[/color]


Sorry! The codine must be working. Here's the code:

<html>
<head>
<script type="text/javascript">
function click() {
var div = document.getElementById("test");
var input = document.getElementById("hidden_input");
div.innerHTML = "changed";
input.value = "changed";
alert(input.value);
}
function doalert() {
alert("alert");
}
</script>
</head>
<body>
<div id="test">id: test</div>
<input type="hidden" name="hidden" value="initial" id="hidden_input"
/>
<a href="#" onclick="doalert(); click();">test</a>
</body>
</html>

BootNic
Guest
 
Posts: n/a
#3: Feb 9 '06

re: i'm doing something wrong with this function...


> "rwsims@gmail.com" <rwsims@gmail.com> wrote:[color=blue]
> news:1139455853.886036.217910@g14g2000cwa.googlegr oups.com....
>
> rws...@gmail.com wrote:[color=green]
>> This works in firefox, not at all in ie6. I'm not getting any
>> errors, but only the doalert() function works, not the click()
>> function. I'm sure there's something obvious, but I'm just not
>> seeing it. Help would be greatly appreciated.[/color]
>
>
> Sorry! The codine must be working. Here's the code:
>
> <html>
> <head>
> <script type="text/javascript">
> function click() {
> var div = document.getElementById("test");
> var input = document.getElementById("hidden_input");
> div.innerHTML = "changed";
> input.value = "changed";
> alert(input.value);
> }
> function doalert() {
> alert("alert");
> }
> </script>
> </head>
> <body>
> <div id="test">id: test</div>
> <input type="hidden" name="hidden" value="initial" id="hidden_input"
> />
> <a href="#" onclick="doalert(); click();">test</a>
> </body>
> </html>[/color]

Try renaming your function click() to say myclick().

--
BootNic Wednesday, February 08, 2006 10:53 PM

"The POP3 server service depends on the SMTP server service, which
failed to start because of the following error: The operation
completed successfully."
*Windows NT Server v3.51*


RobG
Guest
 
Posts: n/a
#4: Feb 9 '06

re: i'm doing something wrong with this function...


rwsims@gmail.com wrote:[color=blue]
> rws...@gmail.com wrote:
>[color=green]
>>This works in firefox, not at all in ie6. I'm not getting any errors,
>>but only the doalert() function works, not the click() function. I'm
>>sure there's something obvious, but I'm just not seeing it. Help would
>>be greatly appreciated.[/color]
>
>
>
> Sorry! The codine must be working. Here's the code:
>
> <html>
> <head>
> <script type="text/javascript">
> function click() {[/color]

This creates a property of the global object called 'click'.

[color=blue]
> var div = document.getElementById("test");
> var input = document.getElementById("hidden_input");
> div.innerHTML = "changed";
> input.value = "changed";
> alert(input.value);
> }
> function doalert() {
> alert("alert");
> }
> </script>
> </head>
> <body>
> <div id="test">id: test</div>
> <input type="hidden" name="hidden" value="initial" id="hidden_input"
> />
> <a href="#" onclick="doalert(); click();">test</a>[/color]
^^^^^^^

The HTML onclick attribute is used to associate script with the 'click'
event. How that happens in IE is different to other browsers.

In IE, if an element has an onclick attribute, it's equivalent DOM
object is given a hidden[1] 'click' property which will mask your click
function that is attached to the global object higher up the scope chain.

In Firefox, the element doesn't have a click property (the event model
is quite different to IE's) so the global click() function runs.


1. The 'click' property is not enumerable, it's not shown when using
using for..in, but can be seen if accessed explicitly using:

<div onclick="alert(this.click);">...</div>

In Gecko browsers the above shows 'undefined', in IE it shows:

function click(){
[native code]
}


--
Rob
rwalrus
Guest
 
Posts: n/a
#5: Feb 9 '06

re: i'm doing something wrong with this function...


RobG wrote:[color=blue]
> rwsims@gmail.com wrote:[color=green]
> > rws...@gmail.com wrote:
> >[color=darkred]
> >>This works in firefox, not at all in ie6. I'm not getting any errors,
> >>but only the doalert() function works, not the click() function. I'm
> >>sure there's something obvious, but I'm just not seeing it. Help would
> >>be greatly appreciated.[/color]
> >
> >
> >
> > Sorry! The codine must be working. Here's the code:
> >
> > <html>
> > <head>
> > <script type="text/javascript">
> > function click() {[/color]
>
> This creates a property of the global object called 'click'.
>
>[color=green]
> > var div = document.getElementById("test");
> > var input = document.getElementById("hidden_input");
> > div.innerHTML = "changed";
> > input.value = "changed";
> > alert(input.value);
> > }
> > function doalert() {
> > alert("alert");
> > }
> > </script>
> > </head>
> > <body>
> > <div id="test">id: test</div>
> > <input type="hidden" name="hidden" value="initial" id="hidden_input"
> > />
> > <a href="#" onclick="doalert(); click();">test</a>[/color]
> ^^^^^^^
>
> The HTML onclick attribute is used to associate script with the 'click'
> event. How that happens in IE is different to other browsers.
>
> In IE, if an element has an onclick attribute, it's equivalent DOM
> object is given a hidden[1] 'click' property which will mask your click
> function that is attached to the global object higher up the scope chain.
>
> In Firefox, the element doesn't have a click property (the event model
> is quite different to IE's) so the global click() function runs.[/color]

[footnote snipped]
[color=blue]
> --
> Rob[/color]

Well I'll be damned. Thanks very much for the explanation.

Guy
Guest
 
Posts: n/a
#6: Feb 10 '06

re: i'm doing something wrong with this function...


rwsims@gmail.com a écrit :[color=blue]
> rws...@gmail.com wrote:
>[color=green]
>>This works in firefox, not at all in ie6. I'm not getting any errors,
>>but only the doalert() function works, not the click() function. I'm
>>sure there's something obvious, but I'm just not seeing it. Help would
>>be greatly appreciated.[/color][/color]

Bonjour

click is certainly reserved word !

G
[color=blue]
>
> Sorry! The codine must be working. Here's the code:
>
> <html>
> <head>
> <script type="text/javascript">
> function click() {[/color]
function doclick() {
[color=blue]
> var div = document.getElementById("test");
> var input = document.getElementById("hidden_input");
> div.innerHTML = "changed";
> input.value = "changed";
> alert(input.value);
> }
> function doalert() {
> alert("alert");
> }
> </script>
> </head>
> <body>
> <div id="test">id: test</div>
> <input type="hidden" name="hidden" value="initial" id="hidden_input"
> />
> <a href="#" onclick="doalert(); click();">test</a>[/color]

<a href="#" onclick="doalert(); doclick();">test</a>
[color=blue]
> </body>
> </html>
>[/color]
RobG
Guest
 
Posts: n/a
#7: Feb 10 '06

re: i'm doing something wrong with this function...


Guy wrote:
[color=blue]
> click is certainly reserved word ![/color]

It's neither reserved or future reserved in ECMAScript Ed 3, maybe
elsewhere?


--
Rob
Closed Thread


Similar JavaScript / Ajax / DHTML bytes