Reputation: 1690
Abit new to html and javascript.
I got a JS script and an html code.
I want to run a specific function in my JS form my html code. how do i do that?
My JS generalRedirect.js:
var redirect = {
test1: function () {
window.alert("sometext");
},
....
My HTML:
..
<script src="@Url.Content(".../Scripts/generalRedirect.js")" type="text/javascript"></script>
Upvotes: 0
Views: 60
Reputation: 5123
Try to do something like this:
<script src='@Url.Content(".../Scripts/generalRedirect.js")' type="text/javascript"></script>
<script>
redirect.test1();
</script>
Upvotes: 1
Reputation: 59232
I want to run a specific function in my JS form my html code. how do i do that?
You can call your function like this:
redirect.test1();
and don't forget to put that inside <script>
tags and also be sure to include the correct file.
Do this:
<script src='@Url.Content(".../Scripts/generalRedirect.js")' type="text/javascript></script>
<script>
redirect.test1();
</script>
Upvotes: 1