0
Why is the ext js file not loading?
<html> <head>NEW PAGE WITH JAVASCRIPT</head> <body> <script type="text/javascript" src="demopage.js"> </script> </body> </html> this is the code but for some reason the js file is not popping up when i run the doc
11 Réponses
+ 3
Try putting it inside <head></head>?
+ 3
@Cheeze:
Put the script in the <head> can just bring more difficulties ( DOM not loaded when JS script start ) ;)
@Glenn Bennett:
Don't you have anything else in the <body> or is this just an extract? You can try to put the <script></script> at the very bottom end of the <body>, to be sure that you don't need access to a DOM element, before it would be available...
Else:
- Is the 'demopage.js' file in the same directory as your html source code?
- Are you trying to link it inside a code playground web document? ( linked documents -- css, js, images, and so on -- must to be hosting anywhere on internet and cannot be accessed localy )
+ 2
@visph Yes, I have a feeling that the .js is not in the same directory.
+ 2
Not: need to be inside <body> ( or <head>, but don't work outside these two )
+ 2
also, can you post the complete code? or a link to it? html and js, to see how they ( should ) interract?
+ 2
Well, the mistake is in your js file: you need to remove all html tags ( including <script> and </script> ), to keep only script content ^^
0
the .html and the.js file are in the same folder
0
would i need to put it outside the body tags ar the bottom
0
also i am using a text editor app and then viewing it through a browser
0
// demo.html doc
<html>
<head>NEW PAGE WITH JAVASCRIPT
</head>
<body> this is the body part of my page
<script type="text/javascript"
src="demopage.js">
</script>
</body>
</html>
//demopage.js page
<html>
<head>
<script type="text/javascript">
alert("this is an alert box")
</script>
</head>
<body>
</body>
</html>
these are my two pages
0
hey thanks alot it works now lol