JavaScript, menu+php ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello i wrote a little script in JavaScript which makes my menu dynamic.
The menu can move with the window while the user moves up or down. But
the problem is that when a user click on a link (of this menu) i want
that the background of the cell stay in a specific color which will be
useful for the user to know which page he is reading. How can i do that ?

     target5 = '_self';

     haut5 = 10;
     largeur5 = 10
     color50 = "#333333";
     color51 = "#555555";
     color52 = "#838383";
     color53 = "#FFFFFF";

     menu5titre = new Array;
     menu5lien = new Array;

       menu5titre[0]= '-home'
       menu5lien[0]= 'index.php'
       menu5titre[1] = '-info coaching';
       menu5lien[1] = 'index.php?p=info';
       menu5titre[2] = '-contrat individuel';
       menu5lien[2] = 'index.php?p=contrat-individuel';
       menu5titre[3] = '-curriculum vitae';
       menu5lien[3] = 'index.php?p=cv';
       menu5titre[4] = '-contact';
       menu5lien[4] = 'index.php?p=contact';

     document.write('<STYLE TYPE="text/css">#menu5 {
position:absolute;top:'+haut5+';left:'+gauche5+'; }</STYLE>');


     function placeMenu5() {
     if (ie4)
     else if (ns6)

     else if (ns4)

     if(ie4 || ns6 || ns4)

     window.onload = placeMenu5;
     document.write('<SPAN ID=menu5><table bgcolor="'+color50+'"
border=0 cellspacing=1 cellpadding=0 WIDTH=150><tr

Here is the cell that i want
colored while reading a document.
I mean, only the specific line

 >  <TD
       document.write('<TR bgcolor='+color51+'><TD
FACE="Verdana, Arial" SIZE=1><B><A HREF="'+menu5lien[a]+'"

Re: JavaScript, menu+php ?


Quoted text here. Click to load it

Use the hash and attach it to the url.

Infinity has its limits.

Re: JavaScript, menu+php ?

Neredbojias a écrit :
Quoted text here. Click to load it
I used PHP...

Re: JavaScript, menu+php ?

Yves Lange wrote:
Quoted text here. Click to load it

Cell? Since when is navigation tabular data? I'd use a ul.

Quoted text here. Click to load it

Quick & easy solution:
I have several pages qith unique names, which are valid classnames.
On every pageload the class of the body is set to that name, and in the list
(and elsewhere), the li's have also classes. The following CSS takes care of
the rest:

.page1 .nav_page1{background-color: #020202;}
.page2 .nav_page2{background-color: #020202;}
.page3 .nav_page3{background-color: #020202;}

Offcourse, if you're building the page using PHP, nothing stops you to make
a class "selected", and check which page is requested with PHP. Just attach
the class to the navigation item of the loaded page.

Rik Wasmus

Site Timeline