The Little Guy Posted February 14, 2010 Share Posted February 14, 2010 I am linking to a javascript file from the file: view.php When I use this in the file: <script type="text/javascript" src="/display/scripts.js"></script> it works fine. I then deciede to move all the html that is in the head of the page (the main content on every page) outside the root to a folder called incl and in its place put: include '../incl/head.php'; all the contents load up fine, but the javascript no longer works, and I get the following error: Resource interpreted as script but transferred with MIME type text/html. Why does is it doing this? Btw, I moved all this to a new file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="/display/scripts.js"></script> <title>Nawdog</title> <link rel="stylesheet" href="/incl/css/style.css" /></head> <body> <div class="container"> <?php if($_page != '/index.php' && $_page != '/'){ echo '<a href="/"><img src="/images/main/logo.png" alt="Logo" /></a>'; }else{ echo '<img src="/images/main/logo.png" alt="Logo" />'; } ?> <div class="login"> <?php if(!$_SESSION['logged']){ echo '<form action="/process/login.php" method="post"> <p> <label for="username">USERNAME:</label><br><input type="text" name="username" class="input" /> </p> <p> <label for="password">PASSWORD:</label><br><input type="password" name="password" class="input" /> </p> <p style="margin-top:20px"> <input type="submit" value="Login" /> <input type="checkbox" name="remember" id="remember" /> <label for="remember">Remember me</label> </p> <p> <a href="/register.php">Register</a> | <a href="/register">Forgot Password?</a> </p> </form>'; }else{ $user = new User($_SESSION); echo '<p>Welcome, <a href="/home.php">'.$user->name().'</a></p> <p>Uploads: <a href="/home.php">'.$user->numUploads().'</a></p> <ul> <li><a href="">Account Settings</a></li> <li><a href="">Add Content</a></li> </ul> '; } ?> </div> and here is the main part to view.php <?php if(!isset($_GET['id'])){ header("Location: /"); exit; } include '../incl/incl.php'; include '../incl/head.php'; $page = new Page(); $page->item = $_GET['id']; $page->go(); ?> Link to comment https://forums.phpfreaks.com/topic/191997-javascript-doesnt-work-when-included/ Share on other sites More sharing options...
The Little Guy Posted February 14, 2010 Author Share Posted February 14, 2010 haha sorry, my mistake, I had two js tags, and I removed the wrong one (the correct linking one). So basically I was linking to a js file that didn't exist Link to comment https://forums.phpfreaks.com/topic/191997-javascript-doesnt-work-when-included/#findComment-1011991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.