ONCLICK event not firing in IE6

N

Nick72

Hi,

I've been reading through tons of posts regarding the problems people
have encountered with getting javascript functions to trigger when
called from onclick events... But so far, I haven't found a solution
that works for me...

I am trying to launch a popup window when the user clicks on an image.

I have managed to get this to work in IE6 by using an image button
(ASP.NET), but this failed in Netscape.
I can now get it to work in Netscape by triggering the window.open
command from the onclick event attached to an <IMG> or <A> tag.

But, this doesn't work in IE6.

The code:

<a href="" onclick="openFullWindow();return false;"><IMG
src="img/space vase web button.jpg"></a>

DOES NOT work in IE6. the HREF parameter is not ignored due to the
'return false;' command... The browser reloads the current page (as
expected) but the javascript procedure 'openFullWindow()' is never
called.

Can anyone provide a solution to my problem?

I'm kind of new to all these languages...

Thanks,

Nick
 
L

Lasse Reichstein Nielsen

The code:

<a href="" onclick="openFullWindow();return false;"><IMG
src="img/space vase web button.jpg"></a>

DOES NOT work in IE6. the HREF parameter is not ignored due to the
'return false;' command...

That symptom suggests an error in the OpenFullWindow function. If
there is a Javascript error prior to the execution of "return false",
then false is not returned and the link is followed as normal.

Are there any error messages? (You have set IE to display Javascript
errors, right? <URL:http://jibbering.com/faq/#FAQ4_43>).

/L
 
N

nick lankester

Doh! In the tradition of 'only finding the problem once you've asked a
question on usenet!', I discovered the prob as soon as I hit submit in
google!

You were right... The problem was that I had assigned a 'name' parameter
to the window I was creating using window.open in the openFullWindow()
procedure.

I removed it and hey presto! it all works...
I don't know why this should have caused a problem, as I read somewhere
that it was a good idea to always name the windows... ?!?!

Thanks for your reply,

Nick
 
L

Lasse Reichstein Nielsen

nick lankester said:
You were right... The problem was that I had assigned a 'name' parameter
to the window I was creating using window.open in the openFullWindow()
procedure.

I removed it and hey presto! it all works...
I don't know why this should have caused a problem, as I read somewhere
that it was a good idea to always name the windows... ?!?!

Did your name contain a space?

The window.open function is documented to required the first two
arguments:
<URL:http://www.mozilla.org/docs/dom/domref/dom_window_ref76.html#1019331>
In IE, all arguments are optional, but apparently not in Gecko based
browsers.

If you don't plan on reusing the window, opening other links into the
same window, then you don't need to give it a name. You can then just
give "_blank" as the name argument to the function. That will create
a new, unnamed window.

/L
 
N

nick lankester

Ahh, yes... That must have been the problem.

A short name with no spaces works fine...


Can you recommend any books or websites that I can use as a reference
that contain this kind of information?

At the moment I'm learning by studying other sites, which is sloooow
going!

Thanks again,


Nick
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top