FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Load scripts from another file

 


NewGuyinTown
I want to know if it's possible to load scripts from a different file [instead of rewriting the same codes for every page] just using HTML and CSS. Something similar to PHP's include function [excluding the use of frames, I don't like frames].
Rhysige
<!--#include file="inc/footer.html" -->

^ that may/may not work depending on your server but you should be able to include files using something like that on your normal HTML page.
hexkid
NewGuyinTown wrote:
I want to know if it's possible to load scripts from a different file [instead of rewriting the same codes for every page] just using HTML and CSS. Something similar to PHP's include function [excluding the use of frames, I don't like frames].


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>example</title>
  <script type="text/javascript" src="f.js"></script>
</head>
<body onload="ff();">
</body>
</html>

Code:
/* f.js */
function ff() {
  alert('Yay!');
}
darkness
The hex kid is right. Simple write a script. Save it as .js (script must be in javascript). simply type in you html or other file
Code:
<script src"[your-name-of-script-here].js"></script>

Then your ready to include. symply copy the code in everypage you wan't and then.... your own includer
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.