user1500300
user1500300

Reputation: 67

Inline Javascript and External Javascript block each other

I have this html code that contains both inline and external javascript:

<!DOCTYPE html>
<html>

<body>

<script>

alert('hello');

alert('world');

</script>

<script src="somedo.js"/>

</body>

</html>

somdo.js:

alert('executed');

When the inline code is put on top of the external javascript, the external javascript never executes. When the external is on top, the inline javascript never executes.

Can someone help please.

Upvotes: 2

Views: 224

Answers (2)

abhiagNitk
abhiagNitk

Reputation: 1067

Add an end script tag and probably you are specifying the wrong name of the js file. If that's the case as well, please correct it.

<!DOCTYPE html>
<html>    
<body>    
<script>    
alert('hello');    
alert('world');    
</script>    
<script src="somedo.js"></script>   
</body>
</html>

Upvotes: 1

Ahmed Salama
Ahmed Salama

Reputation: 2825

Script tag must has end tag so it should be like that

<script src="somedo.js"></script>

not

<script src="somedo.js"/>

This is the problem .

Upvotes: 3

Related Questions