Reputation: 1
ive got a question is it possible to link an item to start another javascript? possibly with an on click funktion ?
so that the javascript only starts once you click an item on the navigation bar?
Upvotes: 0
Views: 69
Reputation: 784
yes, using event handlers.
<a href="#" onclick="alert('you clicked me');">click me</a>
Upvotes: 1
Reputation: 3516
Sure you can:
<a id="test" href="javascript:;">Test</a>
<script type="text/javascript">
var test_object = document.getElementById('test');
test_object.onclick = function() {
alert('hello!');
}
</script>
Upvotes: 0
Reputation: 4906
Yes, this is possible
For example this way:
<script type="text/javascript">
function dosomething( link ) {
alert("Hey, this is " + link );
}
</script>
<a href="javascript:dosomething( this );">click me</a>
Upvotes: 1