Topic: [help] Javascript within php?

Hi there, I'll start with a little background to my problem so it's easier to understand. Basically I managed to modify functions.php so that instead of the navigation header links (Index/User list/Rules etc etc) images are shown. What I would like to do is create a mouseover effect, so that when a user hovers the cursor over the image of say Index, it is replaced by another image. I did try adding the javascript code to the beginning of functions.php (before <?php) and adding the necessary code in my <img> tag, unfortunately this resulted in the following error: (although the mouseover did work)

Warning: Cannot modify header information - headers already sent by (output started at /forums/include/functions.php:1) in /forums/header.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /forums/include/functions.php:1) in /forums/header.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /forums/include/functions.php:1) in /forums/header.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at /forums/include/functions.php:1) in /forums/header.php on line 34


Is there any way I can do this? Being able to use an external js file would be a bonus

Thanks for any help smile

2

Re: [help] Javascript within php?

Why are you using javascript? You could just have used css to set a background image then switch the image on :hover.

Re: [help] Javascript within php?

You shouldn't add it in functions.php, but in header.php. After the JS block that is already there.

And Paul: IE6 doesn't support :hover on anything else than a tags wink

4

Re: [help] Javascript within php?

elbekko wrote:

IE6 doesn't support :hover on anything else than a tags

Yes, and the :hover would indeed be on A tags (the header nav links).  Would that not work?

5

Re: [help] Javascript within php?

Ree wrote:
elbekko wrote:

IE6 doesn't support :hover on anything else than a tags

Yes, and the :hover would indeed be on A tags (the header nav links).  Would that not work?

Thats exactly what I meant. Given that you also have an li element to play with its possible to implement one of the flickerless techniquies to produce something very smooth.

6 (edited by hOtTiGeR 2006-11-23 15:04)

Re: [help] Javascript within php?

How would I go about styling it with css then? As in where would the code go and how would I link it to functions.php? Thanks for the help