Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I have a question about how to get an html page to pull code.
Basically I have a section of my html code, The navigational links, that I am using on all the pages on the site. And because of this, if I want to change one thing, I have to change all of the pages. This can be fun...
I was hoping that I could use a JavaScript call to pull the code in for me. I know that I can make a menu.js file and have the html code pull it in for me, however, I can only get it to write a line, and not create a link. document.write('');, I am guessing that there is a way, but I just don't know how.
If you know how to do this, it would be very useful!
George
Please respond after you have solved your problem to notify who helped you and what solved the problem. Both sides benefit when you do.

Just create a document.write for each line of HTML code. It can be just text, links, images, whatever.
For example, this (spaces added to prevent the code from being parsed by the forum):
< a href="home.htm" >Home Page< /a >
< a href="about.htm" >About Us< /a >
< a href="home.htm" >Home Page< /a >Becomes this:
document.write('< a href="home.htm" >Home Page< /a >');
document.write('< a href="about.htm" >About Us< /a >');
document.write('< a href="home.htm" >Home Page< /a >');The key is to use double quotes in the html code and then use single quotes around the html in the document.writes.
Michael J

Or you could have a totally separate page with the whole navigation in and use a PHP include command (if your webserver supports it that is)
Response Number 3 Reply:
Thank you for your help.
The college that i'm hosting the site with has classes in PHP, So i believe they would support it. However, since I don't know PHP yet, its one of the languages I will learn in the years to come, Java Script will work. I might try messing around with PHP and see if it looks like it works better.
Thanks for all your help, the responces were very useful.
Thanks again!
George
Please respond after you have solved your problem to notify who helped you and what solved the problem. Both sides benefit when you do.
Response Number 4 Reply:
If you already know JavaScript, then PHP will be a breeze to learn as it is almost identical.
Michael J
Sponsored Link
GlassFish vs Tomcat
php/mysql database ![]()
Post LockedThis post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Web Development Forum Home
Sponsored links
Ads by Google
Results for: pulling code?mysql, pull/display random entrySummary: I have a MySQL database with simply one table .... 4 columns, id_number, quote, name, notes I would like, in the header of my website, for a random quote to be pulled from the database upon each arriv...
www.computing.net/answers/webdevel/mysql-pulldisplay-random-entry/3066.html
Pulling info from ftp site to myneSummary: Hi, im trying to pull info from this .txt file "ftp://733081@8.2.120.236/cod/8.2.120.236:28960/main/awe_cod/ban.txt" to my website www.xtpgaming.info so i can post the ban list on the site and people...
www.computing.net/answers/webdevel/pulling-info-from-ftp-site-to-myne/3844.html
simple php codesSummary: is there a php code that reads a file until it finds a certain word or line of text or something of the sort and is possible to highlight the text for deletion or for storing as a variable or somethin...
www.computing.net/answers/webdevel/simple-php-codes/449.html
![]()