• 0

java script basic query


Go to solution Solved by night_stalker_z,

Question

Richard Grant    7
<html>
<body>
<script language="javascript" type="text/javascript" src="object_.js">
alert("working");
</script>
</body>
</html>

Are we able to execute js like this?

 

Or MUST we do this...

<html>
<body>
<script language="javascript" type="text/javascript" src="object_.js">
</script>

<script language="javascript" type="text/javascript">
alert("working");
</script>
</body>
</html>
Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
spacer    988

Script blocks are interpreted and executed in-line as they are processed by the browser. So your first example will work just fine.

 

This is also the reason why most large javascript files and script blocks are added at the end of the body rather than the head of the document. The page will fully load and render while the javascript is being processed.

Link to post
Share on other sites
  • 0
Richard Grant    7

Script blocks are interpreted and executed in-line as they are processed by the browser. So your first example will work just fine.

 

This is also the reason why most large javascript files and script blocks are added at the end of the body rather than the head of the document. The page will fully load and render while the javascript is being processed.

 

That what i thought but the code inside the blocks are not executing. the src link is correct and the console is not outputting any errors.

The second example is working fine. Why isnt't the first? Odd stuff here.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.