Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  25] [ 4]  / answers: 1 / hits: 17037  / 11 Years ago, fri, july 5, 2013, 12:00:00

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!


More From » javascript

 Answers
3

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>

[#77173] Thursday, July 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;