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

R

rwsims

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.
 
R

rwsims

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.


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>
 
B

BootNic

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>

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*
 
R

RobG

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

<html>
<head>
<script type="text/javascript">
function click() {

This creates a property of the global object called '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>
^^^^^^^

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]
}
 
G

Guy

(e-mail address removed) a écrit :
Bonjour

click is certainly reserved word !

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

<html>
<head>
<script type="text/javascript">
function click() {
function doclick() {
 
R

rwalrus

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

<html>
<head>
<script type="text/javascript">
function click() {

This creates a property of the global object called '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>
^^^^^^^

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.

[footnote snipped]

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

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
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top