473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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

Feb 9 '06 #1
6 1345
rws...@gmail.com wrote:
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>

Feb 9 '06 #2
> "rw****@gmail.com" <rw****@gmail.com> wrote:
news:11**********************@g14g2000cwa.googlegr oups.com....

rws...@gmail.com wrote:
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>


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*
Feb 9 '06 #3
rw****@gmail.com wrote:
rws...@gmail.com wrote:
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() {


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]
}
--
Rob
Feb 9 '06 #4
RobG wrote:
rw****@gmail.com wrote:
rws...@gmail.com wrote:
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() {


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]
--
Rob


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

Feb 9 '06 #5
Guy
rw****@gmail.com a écrit :
rws...@gmail.com wrote:
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.

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() {
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>
<a href="#" onclick="doalert(); doclick();">test</a>
</body>
</html>

Feb 10 '06 #6
Guy wrote:
click is certainly reserved word !


It's neither reserved or future reserved in ECMAScript Ed 3, maybe
elsewhere?
--
Rob
Feb 10 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michel Rouzic | last post by:
I got a loop checking if the system time has took one more second or not since last iteration, works nicely, but it uses the whole CPU. I've read many previous topics on c.l.c about wait() type...
15
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str,...
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
16
by: SirG | last post by:
I'm looking for an explanation of why one piece of code works and another does not. I have to warn you that this is the first piece of Javascript I've ever written, so if there is a better way or a...
23
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.