0

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>

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

tried : <script src="@Url.Content(".../Scripts/generalRedirect.js")" type="text/javascript"> redirect.test1() </script> , not working
1

Try to do something like this:

 <script src='@Url.Content(".../Scripts/generalRedirect.js")' type="text/javascript"></script>
 <script>
     redirect.test1();
</script>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.