/    Sign up×
Community /Pin to ProfileBookmark

Trouble moving javascript to external file

I have downloaded a really cool foldout menu script for my web pages and have moved the part that goes in the <head> to an external file. So far so good.

My question is what can I do with the <body> part that contains all the links? It is a menu that uses an unordered list for all the links and so is normal <html> script. Yet this is what I will potentially change a lot (adding and deleting links) and I don’t want to include the same list on EVERY page of the site… Any suggestions? Do I have to script the entire menu in javascript and steer clear of any html input? If so, where can I find info on this? (preferrably some free code that I can download ?

Thanks so much to whoever can help

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoMar 09.2006 — Either use PHP includes, or Iframes.
Copy linkTweet thisAlerts:
@brynauthorMar 09.2006 — Is that relatively simple? I'm not that familiar with PHP and don't know what Iframes is...
Copy linkTweet thisAlerts:
@konithomimoMar 09.2006 — If your server supports PHP then you simply create a page with just the menu on it, and then save it as a .php file instead of .html

Next save all of your pages as .php files instead of .html files.

Then just use an include to put it into each page. For example, lets say you name the page menu.php

To include it just add:

<?php include 'menu.php';?>

to every page whereever you want it to display at. Then you only have to edit menu.php to have it be changed on every page.
×

Success!

Help @bryn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...