| Code: |
// Navigation menu in every page
document.write('<span class="genmed" style="line-height:150%">');
document.write('<a href="index.html">Index</a><br />');
document.write('<a href="forum.html">Forum</a><br />');
document.write('<a href="download.html">Download</a><br />');
document.write('<a href="members.html">Members</a><br />');
document.write('<a href="help.html">Help</a><br />');
document.write('</span>'); |
I saved this as nav.js and I wrote this in index.html :
| Code: |
| <script type="text/javascript" src="nav.js"></script> |
I don't know whats the problem , please help me . thanks .
Firstly you're probably already doing this but just in case....
make sure you have a <SCRIPT LANGUAGE="javascript"> at the start and ending it with </SCRIPT>
Now moving on to what I think the problem is.. you're using double-quotes inside your single quotes. It's supposed to be the other way around. For example:
document.write('<a href="index.html">Index</a><br />');
should be
document.write("<a href='index.html'>Index</a><br />");
but I really dont know what I'm talking about with js i just looked that up form a tutorial site just now to try and solve the riddle for fun. Lemme know if I'm right! 
| djcaution wrote: |
document.write('<a href="index.html">Index</a><br />');
should be
document.write("<a href='index.html'>Index</a><br />");
|
Shouldnt make a difference. I cant see any problem with the code but then i dont know alot about JS. Quotes shouldn't matter though as long as you are consistant.
Why dont you just use PHP to do this, it'd be much easier?
Last edited by JustaMin on Sun Dec 11, 2005 4:52 pm; edited 1 time in total
The problem are indeed the double-qoutes inside the single qoutes, but I don't think changing it the the other way around would solve the problem in all browsers.
Better is to type a backslash before each qoute that has to be interpreted as text, like this:
| Code: |
// Navigation menu in every page
document.write('<span class=\"genmed\" style=\"line-height:150%\">');
document.write('<a href=\"index.html\">Index</a><br />');
document.write('<a href=\"forum.html\">Forum</a><br />');
document.write('<a href=\"download.html\">Download</a><br />');
document.write('<a href=\"members.html\">Members</a><br />');
document.write('<a href=\"help.html\">Help</a><br />');
document.write('</span>'); |
I just hope you are planning to give it a better lay-out??

Well, the first thing I would like to say is that your script works properly for me - or almoust properly.
Perhaps you should remove the <br /> tags if you want to get a horizontal menu, otherwise replace the inline <span> container with the block <p> or <div> one.
If you have no output at all, check whether (1) the index.html and nav.js files is in the same directory and (2) the nav.js filename is exactly in lower case.
Don't worry about double quotes inside of single ones because it is in common use for javascript outputting HTML code. It seems quite comfortable due to you can still use double quotes with attributes of HTML elements.
Please note the ' language="JavaScript" ' attribute is deprecated in modern (X)HTML standards. The ' type="text/javascript" ' is enough.
Okay , I will try it out first . Please check back soon , maybe I need help again .
lol , I tried what u all say and it remains the same . I can't figure what happened too ... Maybe I use too much javascript in the same page ? I used about 4 ...
lol , u know what happened ? I created the js file by :
Right Click > New > RTF Document
And that's the problem !! Solved now !