Click here to Skip to main content
12,951,034 members (58,916 online)
Click here to Skip to main content


7 bookmarked
Posted 15 Nov 2006

AJAX but accessible links

, 15 Nov 2006
A JavaScript tip to make on the same HTML link a JavaScript call or a classic navigate for a new tab/ new window/ disabled JavaScript tool.
<script type="text/javascript">

function SmartLink(evt, sender, ajaxJs)
var ctrlid =;
var ctrlhref = sender.href;
var btn = evt.button;
var IE=navigator.appName=='Microsoft Internet Explorer';
if(!IE){ btn ++ ;} 
var classic = false;
if((btn < 2) && (!evt.ctrlKey) && (!evt.shiftKey))
setTimeout("SmartLinkRestaureHref('"+ctrlid+"', '"+ctrlhref+"')",1);
return false;

function SmartLinkRestaureHref(cid, url)
document.getElementById(cid).href = url;
<!-- [/reusable functions] -->
<script type="text/javascript">
function MyAjaxLink1()
// my ajax method
alert('i can make a ajax call here');

<a id="SmartLink1" href="" onclick="SmartLink(event, this, 'MyAjaxLink1()');">my smart link 1</a>
<li>a simple click on the link : javascript call</li>
<li>a simple click on the link without javascript : classic navigate</li>
<li>open the link on the a new tab/ new window : switch to classic navigate</li>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
France France
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 15 Nov 2006
Article Copyright 2006 by seubi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid