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 trial


Keith Greatz
Keith Greatz
4,377 Points

Header 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>
<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>
<img src="img/spade.png" id="spade">
<h1>Keiffys Games</h1>
<span>Only 40 Years Behind The Times</span>   
<div id="charinfo">
<div id='output'>


<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>&copy; 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>
<script src="scripts/testpage.js" type="text/javascript" ></script>


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.


1 Answer

Tony Nguyen
Tony Nguyen
24,934 Points

Yoo, 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>
Keith Greatz
Keith Greatz
4,377 Points

Yea 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
Keith Greatz
4,377 Points

Shit 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!