• 0

java script basic query


Go to solution Solved by night_stalker_z,

Question

Richard Grant
<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

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

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
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.