Replace part of page with additional html

N

Nonee

Hello-

I am designing a website with a menu and I would like to place
the menu (which is in a table) on every page. I would like to be able
to call an external javascript function call to write it but I haven't
quite figured out how. I know that document.write('blah blah') could
do it but that completely rewrites the entire site while I only want
to put the table there, in between a title image and the rest of the
web content. I know there is innerhtml calls for IE but 1) I am not
sure how it works and 2) I rather not shoot myself in the foot in the
cross-compatibility factor.

Any ideas?

Thanks,

Josh
 
R

Roy Schestowitz

Nonee said:
Hello-

I am designing a website with a menu and I would like to place
the menu (which is in a table) on every page. I would like to be able
to call an external javascript function call to write it but I haven't
quite figured out how.


JavaScript runs on the client's side. Why not use Server Side Includes
(SSI)? You can also use Perl script to add the menu offline.

I have some shell scripts that will apply the changes to a menu recursively.
I use it all the time for very many purposes including embedment of RSS
feeds in pages: http://www.schestowitz.com/Software/Search_and_Replace/

I know that document.write('blah blah') could
do it but that completely rewrites the entire site while I only want
to put the table there, in between a title image and the rest of the
web content. I know there is innerhtml calls for IE but 1) I am not
sure how it works and 2) I rather not shoot myself in the foot in the
cross-compatibility factor.

Any ideas?

Thanks,

Josh


Try to avoid JavaScript. Cross(platform)-compatibility would not be an
issue, but browser compatibility would. There is also a performance
penalty.

Roy
 
N

Neredbojias

With neither quill nor qualm, Nonee quothed
Hello-

I am designing a website with a menu and I would like to place
the menu (which is in a table) on every page. I would like to be able
to call an external javascript function call to write it but I haven't
quite figured out how. I know that document.write('blah blah') could
do it but that completely rewrites the entire site while I only want
to put the table there, in between a title image and the rest of the
web content. I know there is innerhtml calls for IE but 1) I am not
sure how it works and 2) I rather not shoot myself in the foot in the
cross-compatibility factor.

Any ideas?

Though I agree with the suggestion about server-side being better, you
can call an external javascript with something like:

<script type="text/javascript" src="ext1.js"></script>

The ext1.js is another file which should contain a document.write that
can be inserted wherever you want in the body of the main page(s).
 
S

seven-G

Hi Josh!

You can create a "template" if you have Dreamweaver. Apply he template
to any additional page you create and that's it. Dreamweaver has very
simple instructions in its tutorial that can guide you through the
process. Later if you want to change or add a link to your main menu,
just open the template and save it. Then you have to open all the rest
of the pages and press "update" under the template menu and that's it!
Try it, once you read the tutorial you'll realize it is very simple.

Good Luck!

Gabylana
www.seven-g.net
 
S

seven-G

Hi Josh!

You can create a "template" if you have Dreamweaver. Apply he template
to any additional page you create and that's it. Dreamweaver has very
simple instructions in its tutorial that can guide you through the
process. Later if you want to change or add a link to your main menu,
just open the template and save it. Then you have to open all the rest
of the pages and press "update" under the template menu and that's it!
Try it, once you read the tutorial you'll realize it is very simple.

Good Luck!

Gabylana
www.seven-g.net
 
N

Nonee

Perfect! I am using dreamweaver and that works great!

Thank you Gabylana and everyone else for your replies.

I really appreciate it!
 
D

dorayme

From: Nonee said:
Hello-

I am designing a website with a menu and I would like to place
the menu (which is in a table) on every page. I would like to be able
to call an external javascript function call to write it but I haven't
quite figured out how. I know that document.write('blah blah') could
do it but that completely rewrites the entire site while I only want
to put the table there, in between a title image and the rest of the
web content. I know there is innerhtml calls for IE but 1) I am not
sure how it works and 2) I rather not shoot myself in the foot in the
cross-compatibility factor.

Any ideas?

Thanks,

Josh

You have a menu and you would like to place it it on every page. How many
pages are we talking here? If just a few, like 10 to 50 then just place it
on every page. This way there is no need to use javascript (which is not
always on and/or working in browsers) or get fancy. You can get fancier
using "includes" and php and server side set ups. But think whether there is
a true need in your case. (What's this about a bit of "write" in javascript
"completely rewriting the entire site"? This sounds a bit dramatic and
unlikely? You can just write the teeniest weeniest thing with it.

dorayme
 
N

Nonee

Actually since I have all of your attentions... I am having a problem
with the document.write('') method. Everytime I use it, it rewrites
the entire page. I am not sure why that is. Could including a
function call that uses the doc.write method in the body onload event
be doing it? It just completely blanks out the entire page and only
puts in the doc.write string. Any ideas?

Thanks again,

Josh

P.S. Oh, and Dorayme, yes it is under 50 pages, I just thought there
could be an easier way. The dreamweaver template idea worked very
well. I am just lazy I guess... : )
 
M

Mark Parnell

Previously in alt.html said:
I am having a problem
with the document.write('') method. Everytime I use it, it rewrites
the entire page. I am not sure why that is. Could including a
function call that uses the doc.write method in the body onload event
be doing it? It just completely blanks out the entire page and only
puts in the doc.write string. Any ideas?

If you are using it for something as essential as a menu, stop it.

As far as the actual behaviour you're describing, it's impossible to say
without a URL what is causing it. You may also get better responses to
that question in news://comp.lang.javascript since it's a Javascript
issue (though a URL will probably still be necessary).
 
D

dorayme

From: Nonee said:
P.S. Oh, and Dorayme, yes it is under 50 pages, I just thought there
could be an easier way. The dreamweaver template idea worked very
well. I am just lazy I guess... : )

I understand. Personally I hate all these wsiwigs but I guess they can
really save time. But if it is for not a huge amount of pages, this is no
big deal. Happily enough, I insert changes and repeated elements in multiple
pages via search and replace functions in my text editor, sometimes using
grep patterns, and it would not be any slower than Dreamweaver.

"Includes" have the advantage that when you change the menu, you just upload
it once to a server. Otherwise, however easily you insert the code on each
page, you still need to upload them to the server. But again, it does not
take much as you can do this in great dollops of multi files too. Not as
elegant, true... but sshh, who is to know?

dorayme
 
N

Neredbojias

With neither quill nor qualm, Nonee quothed
Actually since I have all of your attentions... I am having a problem
with the document.write('') method. Everytime I use it, it rewrites
the entire page. I am not sure why that is. Could including a
function call that uses the doc.write method in the body onload event
be doing it?

Yes. Without double-checking this, I'm pretty sure you cannot write to
the page once it's "loaded" - as in "onloaded." I believe I tried that
once with results similar to yours.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top