Reputation: 157
This is the link that I have:
href='" . $ajax_like_link . "' data-task='like' data-post_id='" . $post_id . "' data-nonce='" . $nonce . "'>";
And I want to replace the displayed link value from status and set to javascript:void(0)
.
How can I accomplish this?
Upvotes: 2
Views: 24612
Reputation: 351
a more shorter syntax of doing this is
<a href="javascript:;" onclick="location.href='" . $ajax_like_link . "'">Link</a>
and there are many other ways of doing this, you can create a jquery function and just put the url in the attibute. e.g
<a href="javascript:;" rel='" . $ajax_like_link . "'" class="goto">Link</a>
$(".goto").click(function() {
var gotolink = $(this).attr('rel')
if(gotolink!=undefined || gotolink!='')
location.href = gotolink;
});
Upvotes: 0
Reputation: 9156
You can set the status with window.status=''
but most browsers will block attempts to change the status line by default for security reasons
<a href="link" onmouseover="window.status='javascript:void(0)';" onmouseout="window.status='';">link here</a>
So a better way is to
<a href="javascript:void(0)" onclick="location.href='" . $ajax_like_link . "'">Link</a>
Upvotes: 0
Reputation: 7836
Try this:
<a href="javascript:void(0)" onclick="location.href='" . $ajax_like_link . "'">Link</a>
Upvotes: 6
Reputation: 11717
you can do it by calling javascript function instead of link in href:
<a href='javascript:void(0)' onclick='gotoLink(\"". $ajax_like_link ."\")' .......>link</a>
<script>
function gotoLink(url) {
window.location = url;
}
</script>
Upvotes: 0