Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKeith Greatz
4,377 PointsHeader Text is lost when JS prompt is included
Hi, I seem to have come across a problem when loading a basic JS prompt, it actually hides my header (well all the text in it anyway, when i place my script tags in the <head> section of the HTML it doesn't but ultimately I need the Java script to be loaded last on the page. any ideas why this is happening?
var menu = prompt("HEY");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/normalize.css" rel="stylesheet" type="text/css">
<link href="css/gamepage.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie|Source+Code+Pro:200,300,400,500,600,700,900|Inconsolata:400,700|Orbitron:400,500,700,900|Chewy' rel='stylesheet' type='text/css'>
<title>Keiffy's Games</title>
</head>
<body>
<header>
<img src="img/spade.png" id="spade">
<h1>Keiffys Games</h1>
<span>Only 40 Years Behind The Times</span>
</header>
<div id="charinfo">
</div>
<div id='output'>
</div>
</body>
<footer>
<a href="https://www.youtube.com/channel/UChsr1Kmm49Jwhl2TKo5ZLJQ"><img src="img/youtube.jpg" alt="Youtube Logo" class="social-icon"></a>
<a href="https://www.facebook.com/Keiffy101"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
<p>© 2015 Keith Greatz.</p>
<p>Tutorials from <a href="https://teamtreehouse.com">https://teamtreehouse.com</a> have helped me immensely with creation of this site</p>
<a href="sitehistory.html">Site History</a>
</footer>
<script src="scripts/testpage.js" type="text/javascript" ></script>
</html>
Thanks in advance for any suggestions, I keep thinking maybe i should stop trying to write my own stuff until i do more Jquery courses.
Keiffy101
1 Answer
Tony Nguyen
24,934 PointsYoo, Whaddup Keith.
Your script tag needs to be above the closing body tag. That way, your whole web page loads first and then loads the JavaScript after.
<script src="scripts/testpage.js" type="text/javascript" ></script>
</body>
Keith Greatz
4,377 PointsKeith Greatz
4,377 PointsYea I already tried that, it turns out when I change the css font family to a generic one that it no longer disappears so I guess it has something to do with loading the font from google fonts... sucks i really wanted that font, I'll do some more research when I get back online.
Keith Greatz
4,377 PointsKeith Greatz
4,377 PointsShit is messed up, it seems sometimes my JS erases one image from my page sometimes none sometimes all... its not just a font thing... MESSED UP!