2

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.

2 Answers 2

3

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 .

Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.