|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
JS equivalent to php include file
I have tried it using php ie include 'somefile.js'; in the header, however it doesn't work. I was wondering if there's a javascript way of doing it so the file could be called in between the javascript tags in the header. the js data I have to put in another file are a load of vars etc.
ie: <script type="text/javascript" language="javascript"> var blah blah .................... function blah blah </script> |
|
#3
|
|||||
|
|||||
|
inc vars
As long as you reference the vars before you need them, they should be available for subsequent scripts. eg.
inc_test.html HTML Code:
vars.js header.js footer.js EDIT :lol: I just checked out the link Icon posted. Very good! Last edited by Mittineague : September 20th, 2006 at 09:38 AM. |
|
#4
|
||||
|
||||
|
It works!
Thanks Mittineague!
It was just the header info that I was concerned about as the my files which used the same js var were all 'top heavy' if you see what I mean, and now, if there are any changes to be made, I can do it in just one file. Life changing stuff! It's made a big difference. As mentioned before, I was trying to do the same thing before in php, without much success. And, well, thanks Icon for that link, I haven't had time to read in between the lines as yet, I don't get the joke, but I'm sure testing out js includes are humourous! |
|
#5
|
||||
|
||||
|
The article shows some methods, including Mittineagues method I think.
Last edited by Icon : September 21st, 2006 at 07:23 AM. Reason: - Misunderstood something, post was superfluous - |
|
#6
|
||||
|
||||
|
Random include
Yeh thanks for that link. I had a chance to read some it. I like the random include which is useful for a selection of advertising banners on my site.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > JS equivalent to php include file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|