I had made flag and made my previous question deleted because of missunderstanding.
I'm working on a classic asp project.
let's say you have so many <script></script>
tags in your code.
For instance:
line 10: <script> ..function 1 definition here..</script>
line 200: <script> .. function 2 definition here..</script>
line 5000: <script> ..function 3 definition here..</script>
also at line 6000: I have another tag which is trying to call function1.
is that possible without using *.js file ?
For instance:
line 6000:
<script> function1(); </script>
Those scripts are not defined in <head>
tag.
I know its not useful but I need to know is there any way of it or not.
Hope its more clear now!
anything inside the script tags gets run immediately. if you define function a()
in your first script element, then it will add a function called a
to your global namespace. any javascript you execute later on in other script elements will have access to it.
<script type="text/javascript">
function a() {
alert('hi');
}
</script>
...
<script type="text/javascript">
a();
</script>
Yes, that is possible, assuming function1
is in the global scope (e.g. not in a wrapper function/self-invoking function).
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