/    Sign up×
Community /Pin to ProfileBookmark

To Stop a hyperlink

hi,
How can I make a a hyper link to be not work. The following example will, clearly, demonstrate
what I, exactly, want to do.
Suppose,

[code]
<a href=”pic.jpg”><img src=”tn_pic.jpg”></a>
[/code]

On the clock on the above link, the browser will load pic.jpg . Now, I want to do something like
the following:

[code]
<a href=”pic.jpg” onClick=”func(this)”><img src=”tn_pic.jpg”></a>
[/code]

The function func() will load pic.jpg inside a popup browser’s window. what I want to do is to
keep the parent page as it’s i.e not changed to pic.jpg.
I, already, done something can do that, but it has a bug. look at the following code,

[code]
function func(p){
p.href = ‘javascript:stopIt()’
}
function stopIt(){
}
[/code]

The problem is when I try to click again on the hyperlink, its href property was changed to
javascript:stopIt() and the pic.jpg was lost.

Is there any suggestions to overcome this problem?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JDec 18.2004 — Please try the following


<a href="pic.jpg" onclick="yourFunction();[B]return false[/B]"><img src="tn_pic.jpg"></a>
Copy linkTweet thisAlerts:
@said_foxauthorDec 18.2004 — Thank you Mr J, your solution is so perfect. Now I will modify func() to eliminate the change of href property value and it will work so nice.

Thank you again.
×

Success!

Help @said_fox spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...