Closed Thread Icon

Topic awaiting preservation: External JS File and PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12931" title="Pages that link to Topic awaiting preservation: External JS File and PHP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: External JS File and PHP <span class="small">(Page 1 of 1)</span>\

 
The Jackal
Paranoid (IV) Inmate

From: The Dark Side of the Moon
Insane since: Jun 2000

posted posted 10-13-2003 20:48

OK, so I added a link to an external JS file in my header.php. Big surprise, it does not work. When I call on the index.php file my JS scripts do not show up. What am I doing wrong?

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 10-13-2003 20:56

The Jackal: Can we see some code or something?

I'd suggest you use 'absolute' links in your incldues so that it always works out where things are from the root so you'd want:

/javascript/my_javascript.js

rather than:

../javascript/my_javascript.js

or:

javascript/my_javascript.js

___________________
Emps

The Emperor dot org

The Jackal
Paranoid (IV) Inmate

From: The Dark Side of the Moon
Insane since: Jun 2000

posted posted 10-13-2003 21:23

Well, the code is as follows. First, your regular link to an external JS file.

code:
<SCRIPT SRC="scripts.js" LANGUAGE="JAVASCRIPT"></SCRIPT>



The header.php looks like this:

code:
<html>
<head>
<title><?php echo "$title"; ?></title>

<link rel="stylesheet" href="style.css">
<SCRIPT SRC="scripts.js" LANGUAGE="JAVASCRIPT"></SCRIPT>
</head>
<body>
My header content here



The index.php is this:

code:
<?php $title = "My Title Here"; ?>
<?php include($DOCUMENT_ROOT . "/header.php");?>
My Content Here
<?php include($DOCUMENT_ROOT . "/footer.php"); ?>



And at last we have the footer:

code:
My Footer Content Here
</body>
</html>



The only thing I can think of is that the JS file is not parsed like it should be when using PHP templates. The include is in the root directory.



[This message has been edited by The Jackal (edited 10-13-2003).]

The Jackal
Paranoid (IV) Inmate

From: The Dark Side of the Moon
Insane since: Jun 2000

posted posted 10-13-2003 21:35

Never mind! I am a retard to day. I failed to upload the actual JS file to my server. I am way to young to suffer from alzheimers! Thanks Emperor.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 10-13-2003 22:42

Always glad to urm........................ help.

I would recommend you also think about doing your links the absolute way so that the link will always work.

___________________
Emps

The Emperor dot org

« BackwardsOnwards »

Show Forum Drop Down Menu