Dice Artist
Dice Artist

Reputation: 1

Javascript link to start another javascript

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

Answers (3)

Niborb
Niborb

Reputation: 784

yes, using event handlers.

<a href="#" onclick="alert('you clicked me');">click me</a>

Upvotes: 1

jaco
jaco

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

bukart
bukart

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

Related Questions