hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Design and Content : javascript includes??
Reply

Forum Jump

javascript includes??

Reply Post New Thread In Web Design and Content Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 10-02-2006, 12:13 PM
Aristotl3 Aristotl3 is offline
Junior Guru Wannabe
 
Join Date: Oct 2005
Posts: 72

javascript includes??


Ok.. here is the deal. I am making a very large website with a drop down javascript menu. I am using HTML includes for various parts of the website (including the menu).

The way it is now, If I need to make any changes to the drop down menu I will have to go to ever page on the website and change the javascript coding.. Is there a way to include this coding (similar to what I am doing with the HTML files)?

Basically, I want to know if there is a way to set up a template where I can make the changes to the coding and not have to make the changes to each individual page..

can anyone help?

thanks



Sponsored Links
  #2  
Old 10-02-2006, 12:43 PM
the_pm the_pm is offline
Community Liaison 2.0
 
Join Date: May 2004
Location: Pflugerville, TX
Posts: 11,222
The answer to your question about an include system is yes, and further, a JavaScript include system is the worst possible way you can create one. Unless your server does not support PHP, ASP, ColdFusion or SSI, I would strictly keep away from serving up critical information, such as site structure, using JavaScript. Stick with server technology. Don't rely on the visitor UA to interpret your site!

With that said, is there a specific reason you're targeting JavaScript, something in your environment that makes it the only option?

__________________
Studio1337___̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡.__Web Design

  #3  
Old 10-02-2006, 01:10 PM
mikey1090 mikey1090 is offline
Web Hosting Evangelist
 
Join Date: Feb 2006
Location: Lancashire, UK
Posts: 472
use php. create a file called header.php. put all your html in this file. then use php <? include "header.php"; ?> to include the files in your pages. when u want to change the pages, you just change header.php, rather than all the pages

Sponsored Links
  #4  
Old 10-02-2006, 02:19 PM
Aristotl3 Aristotl3 is offline
Junior Guru Wannabe
 
Join Date: Oct 2005
Posts: 72
okay.. I know how to do PHP includes, but I'm not sure what you mean by putting all of the HTML in just one file..

Is it possible to just have one inlcude file for the navigation (say: nav.php) which has the HTML/javascript for the navigation and just use that as an include?

  #5  
Old 10-02-2006, 02:35 PM
Aristotl3 Aristotl3 is offline
Junior Guru Wannabe
 
Join Date: Oct 2005
Posts: 72
hmmm, I have tried using the php includes but I can't seem to get it to work so that I only have one file with the javascript code in it.. are there any links out there so I can see how the coding is done???

  #6  
Old 10-02-2006, 02:51 PM
Aristotl3 Aristotl3 is offline
Junior Guru Wannabe
 
Join Date: Oct 2005
Posts: 72
okay.. I got the coding to work.. I always thought that javascript coding needed to go in the <head> part of a website.. The way I have it set up right now, the javascript is loaded in the body part of the website - is there anything wrong with that?

  #7  
Old 10-02-2006, 04:06 PM
the_pm the_pm is offline
Community Liaison 2.0
 
Join Date: May 2004
Location: Pflugerville, TX
Posts: 11,222
If you're using PHP includes, stick all of your JS functions into an external file. Then, use the common script calling mechanism to call those scripts - <script type="text/javascript" src="/path/to/scripts.js"></script>. Finally, place this inside the file that's being included via PHP. That's all there is to it

Remember, you can include files inside included files, inside included files, ad nauseum.

__________________
Studio1337___̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡.__Web Design

Reply

Related posts from TheWhir.com
Title Type Date Posted
Swarmify's New Approach to Content Delivery Uses Site Visitors to Accelerate Content Web Hosting News 2014-04-02 12:05:19
CyrusOne to Build Second Data Center in San Antonio Web Hosting News 2013-08-08 14:40:08
Nasuni Launches Cloud Mirroring Feature to Storage Solution Web Hosting News 2013-08-08 14:15:27
OpenStack and the AWS API Debate Web Hosting News 2013-07-30 14:21:54
Facebook's Recently Acquired Mobile App Platform Parse Launches Web Hosting for Developers Web Hosting News 2013-05-08 10:49:17


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?