How can you do something like this:
<a href="some javascript statement that isn't a function call;" >myLink</a>
And have the js in the href execute when the link is clicked.
<a href="javascript:var hi = 3;" >myLink</a>
Now you can use hi
anywhere to get 3
.
Just put the JS code directly in there:
<a href="#" onclick="a=1;b=2; return false;">fsljk</a>
Though, you should not be doing inline scripting. You should unobtrusively attach event handlers.
<a id="lol" href="/blah">fdsj</a>
<script>
document.getElementById('lol').onclick=function() {
/* code */
};
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With