/    Sign up×
Community /Pin to ProfileBookmark

Use javascript in A Href link for multiple actions

Hi,

I want to be able to provide a single A HREF link on a web page to execute a perl logout script and also display a return URL page determined by the link (i.e. not by the perl logout script). I believe javascript is the way to do this as the perl script is a comon program and I cannot alter the code to display the return URL from there.

The link that works is:
<a href=”#” onClick=”javascript: OpenPopUp(‘/cgi-bin/logout.pl’); return false”>
But the return URL is determined in the logout.pl program (which I cannot change) and I want it to be different.

Is it simply a matter of adding the required return URL as follows:
<a href=”www.abc.com/page.html” onClick=”javascript: OpenPopUp(‘/cgi-bin/script.pl’); return false”>

Will that link execute the logout script as well as returning to the required page? Do I need to retain the return false statement?

Any help would be greatly appreciated as testing this out is quite difficult to determine if the perl logout script has been executed.

Many Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ShortsApr 22.2009 — The return false should stop the link from going to where ever it will go.

What I'd suggest is something like:

[CODE]
<a href="javascript:void(0);" onclick="OpenPopUp('/cgi-bin/script.pl'); window.location='http://www.abc.com/page.html'; return false;">
[/CODE]


Don't worry about the javascript:void(0); I personally just use that over #. One thing, in onclick don't have javascript: . So it opens the popup, then changes window's location to 'http://www.abc.com/page.html'
Copy linkTweet thisAlerts:
@FangApr 22.2009 — logout.pl will change the location of the popup window not the parent window.

Don't use the javascript protocol; it's not a registered protocol.

@ [B]Shorts[/B] The code has accessibility problems; always have a url as a href value, not JavaScript.
×

Success!

Help @paulb 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...