Forum Moderators: open

Message Too Old, No Replies

<A HREF = "Javascript call"> not understood by IE

a quite interesting problem to solve

         

Jerarckill

11:31 am on Jul 6, 2003 (gmt 0)

10+ Year Member



Hello you all!

I have here a quite boring problem with javascript.
I code using UltraEdit => it's not a problem caused by code added by HTML editors and so on.

Well, here is the problem.

the <A HREF = "Javascript:CallMethod()"> is not working as it should. For an obscure reason, the text between "" => "Javascript:CallMethod()" is seen and treated as an URL by my browser (IE 6 / Crazy Browser). I can put whatever i want between these brackets, the result is the same : the browser tries to open the link given in the HREF parameter.

I have tried to use <A HREF = "Javascript:void(0);" and things like that but the result is always the same : the browsers never sees the JavaScript code as it should.

I think the error comes from a configuration in IE or something like that but i can't find any clue.

I would be grateful to anybody who could help me with this one

To be sure, this is some code that is not working :

<a HREF = "javascript: void(0)" onClick = "OpenPage('DisplayPicture.htm', 'Jean-Marie Mengeot', 'images/gallerie_ccd/Mengeot/Normal CCD/image001.jpg')">...<IMG SRC = "..." </A>

theOnclick event works perfectly fine (=> the method is called) but HREF opens another page whose url is Javascript:void(0)

I want to use the HREF parameter to have the cursor changed
(I know that i can use some tricks to show another cursor but it's more work and doesn't solve a problem that shouldn't happen....)

thanks in advance

Jerarckill

killroy

12:00 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how about callign the function like this:

<a href="javascript:callfunction()" onclikc="return false">

?

SN

Xuefer

12:00 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



<a target="_self" HREF="javascript: void(0)" onClick="OpenPage......

or:
<a HREF="javascript: void(0)" onClick="OpenPage......; return false"

Jerarckill

1:11 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



----------------------------------------------------------
how about callign the function like this:
<a href="javascript:callfunction()" onclick="return false">
?
----------------------------------------------------------

this seems to work but it's not the case. The return false statement will make my Href not responding (=> not going anywhere) but the method put inside the" " will not be called at all. => i can't call anything in the HREF parameter like that

----------------------------------------------------------
<a target="_self" HREF="javascript: void(0)" onClick="OpenPage......
or:
<a HREF="javascript: void(0)" onClick="OpenPage......; return false"
----------------------------------------------------------

that's what is told by everybody (and seems to work everywhere :-) but it's not responding in a good way here (Browser tries to open a page called javascript: void(0) instead of being set to null

In fact, i think that the safest way to correct the problem is not using the HREF param at all. I now use :
<A style="cursor:hand" onClick = "Some Javascript Code">Click me</A>

where the style will make the cursor change to a hand and onclick event load the page (or anything else).

That doesn't solve the problem but it's a good way to make things work correctly.

If you have any other idea, they are welcome ;-)

ikbenhet1

1:32 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



Is your base target _blank or _new?
try setting it to "_self" for that link like target="_self"
Solves the problem sometimes for me, specially if you call a function from the javascript that resides in the "other" window..

<edit> i see i this duplicate post, sorry.
<edit>removed useless piece of text

[edited by: ikbenhet1 at 1:46 pm (utc) on July 6, 2003]

claus

1:45 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ohyes... base target might be the reason. Try this syntax as well, while you're at it:

<a href="#" onClick="javascript:doSomething();">

/claus

Xuefer

3:01 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



Jerarckill:
ppl who stick to standards says that, "A[href]" tag is widely misused
but the truth is: even up to IE 6, ":hover" support for "A[href]" element only

do u like to use onmouse*** to simulate ":hover" effect?
do u like to play the click.wav by yourself?
do u like to set border to dotted in onmousedown? (it's a IE effect for clickable link, appears when user click on a link)
and even to simulate the ":active" effect?

if all the answers to the aboves is "no", then u can, and are suggested to use <span> :P