js include
Ok, I know there's a way to do what I'm asking, but I can't find it anywhere...
Well, it's basically an include for javascript, but all you'd see in the source is the include statement (it may or may not be an actual include statement, but it's the only thing I can relate it to). I've seen it before but can't find it...not only good for maintenance but to protect your code as well (obviously). Thanks in advance.
Ben C
-"The exception...is to tap the unexceptional."
Vincent Puglia posted this at 18:17 — 24th July 2000.
They have: 634 posts
Joined: Dec 1999
Hi ben,
The Code:
<script language='javascript' src='somename.js'></script>
The contents/rules:
1) The file can only contain javascript; that means no tags, no html
2) if you must include html, embed it within a string
var myStr="";
or, a javascript method:
document.write("");
Comments:
The use of a *.js file does not protect/hide your code. Nothing does. See the thread posted by quietinthecorner, "no right-click script". It only allows you to centralize your functions & preload them in certain cases.
If you would like to see examples of *.js files in use. Go to my site; half of the pages use the same funcs.js file. If you would like to see the contents, either rightClick the home page or download the file using the *.js.
Vinny
Where the world once stood
the blades of grass cut me still
Rageforth posted this at 03:38 — 29th July 2000.
They have: 56 posts
Joined: Feb 2000
by "include" are you talking about ASP style include where it could put your entire navigation on the page for you just from a couple lines of ASP code? I am bad at explaining things I know. He is what I am trying ot say...
you make your js file like Vincent Puglia said. put the entire code in that js file for your navigation (of course give it a variable name). in the html page you do the <script src="FILE.js"></script> and in the body you put
document.write(NAME_OF_VARIABLE). that would put the navigation on the page for you. that is kinda like an include....javascript style. that way, you update one file and all the pages are changed. did that make sense at all or am i just way to confusing?
The trouble with doing something right the first time is that nobody appreciates how difficult it was.
benc posted this at 22:00 — 2nd August 2000.
They have: 33 posts
Joined: Jul 1999
Thanks Vinny and Rage
Actually, it's not just my javascript that I want site-wide, it's also my nav. I was planning to use SSI for that...speaking of which:
Does that look remotely correct?
Ben C
-"The exception...is to tap the unexceptional."
Rageforth posted this at 13:42 — 3rd August 2000.
They have: 56 posts
Joined: Feb 2000
that works and also
i think they both only work online. don't think they work locally.
i have never used either so i am not 100%. this is what i have read about it. i'll need to try it myself sometime i guess
The trouble with doing something right the first time is that nobody appreciates how difficult it was.
TWTCommish posted this at 17:23 — 3rd August 2000.
They have: 62 posts
Joined: Jun 2000
I don't see any reason to use JavaScript unless you need to...I'd go with SSI.
Or FrontPage Shared Borders! Those are GREEATT! (not sarcasm).
benc posted this at 17:57 — 3rd August 2000.
They have: 33 posts
Joined: Jul 1999
Commy (if I may call you that )-
I'd only use 'javascript includes' (or whatever the hell you want to call them) for javacsript - certainly not HTML. I'd be using the same javascript on all my pages though. Oh, is that what you mean? Just use SSI to include the javascript? I guess that's possible. That's why I want to get down SSI first...
That was my other question - what is the difference between virtual and file? I've seen those before but I don't think I ever came to any conclusion as to which one to use, advantages, disadvantages, etc. Anyone?
Ben C
-"The exception...is to tap the unexceptional."
mjames posted this at 04:50 — 13th August 2000.
They have: 2,064 posts
Joined: Dec 1999
Hey TWTCommish... I'm familiar with .js includes and SSI (used both), but what is Microsoft Shared Borders and how does it work? I've heard of a site that uses it, but never really understood...
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.