Jump to content

Onmouseout/over working on one site, but not the other...


hashamyim

Recommended Posts

Hey there all,

 

I've got two websites on my localhost - on one website the onmouseover / onmouseout functions work absolutely fine, yet when I copy and paste the code into the second website (hosted in a subfolder of the first), it doesn't work anymore... not sure what is preventing the function from running but it doesn't work in IE or firefox...

I've copied and pasted the code from the second website below and put the troublesome text in bold - any help would be greatly appreciated! I have some kitkat chunkys if anyone is interested!

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="X-UA-Compatible" content="IE=8; charset=utf-8" />

<link rel="stylesheet" type="text/css" href="index.css">

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

</script>

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

</script>

</head>

 

<body onLoad="showClock()">

 

<div id="wrap">

 

<div id="logo">

<div id="logopic"><img src="images/logo.png" /></div>

</div>

 

    <div id="header"><img src="images/header.jpg" /></div>

   

    <div id="flags">

      <a href="index.php" onmouseout="swap('en','images/enA.jpg')" onmouseover="swap('en','images/enflag.jpg')"><img name="en" src="images/enA.jpg" /></a>

    </div>

 

<div id="main">   

   

  <div id="showText"></div>

 

    <div id="clock">

<script type="text/javascript">

setInterval(function() { document.getElementById('clock').innerHTML = WTF.now().value; }, 600);

</script>

</div>

   

  <div id="date">

<?php

  $day = date('l');

  $number = date('j');

  $st = date('S');

  $month = date('F');

  $year = date('\'y');

  echo $day;

  echo ', ';

  echo $number;

  echo $st;

  echo ' ';

  echo $month;

  echo ' ';

  echo $year;

  ?>

    </div>

 

    <div id="alphahelp"><a href="http://www.worldtimeformat.com/" target="_blank">?</a></div>

   

  </div>

 

<div id="footer"><img src="images/footer.png" /></div>

 

</div>

</body>

</html>

Link to comment
Share on other sites

It's not working because of the filepaths you supply into your swap() function.  Since the second site is in a subfolder of the first, you will need to use absolute paths to your images to get it to work, or put a forward slash at the beginning of the relative path to force it to look in the base directory for the images folder.

 

<a href="index.php" onmouseout="swap('en','/images/enA.jpg')" onmouseover="swap('en','/images/enflag.jpg')"><img name="en" src="/images/enA.jpg" /></a>

Link to comment
Share on other sites

Actually, now that I look closely, all of your filepaths are relative.  Are any of the images on the page loading at all?  Also, where is the javascripts/ directory in relation to the first and second sites?

 

I still stand by my claim that it is due to faulty filepaths, but I'm beginning to think it's not the images in the swap() function, but rather the <script> tag itself.  Change the src attribute to an absolute path and see if that doesn't fix it.

Link to comment
Share on other sites

Yes, for some reason all the pictures are loading absolutely fine - indeed, even the pre-rollover picture is showing fine - it just doesn't want to roll over!

I tried using the /images/enflag.jpg but that stopped the initial picture from showing, so I guess it doesn't like that!

I really feel like I've tried everything to get this to work, not a clue why it isn't...

 

I've even just tried <a href="index.php" onmouseout="swap('en','http://www.robertjacobs.me.uk/images/menu5.gif')" onmouseover="swap('en','http://www.robertjacobs.me.uk/images/menu5b.png')"><img name="en" src="http://www.robertjacobs.me.uk/images/menu5.gif" /></a> and that doesn't work either.

 

Is it anything to do with the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> or the <meta http-equiv="X-UA-Compatible" content="IE=8; charset=utf-8" /> lines I'm using? I've replaced them with other things to test, but I'm not totally sure what I'm doing in that department!

 

Thanks for your help

Link to comment
Share on other sites

Right, ok - I've found the problem... it was probably stupid and quite frankly, I'm a bit embarassed to admit it, but I hadn't actually defined the function swap() anywhere... The javascript file was included in the other website, but I forgot to copy that over. Yes, I'm a dick - I accept that!

 

Thanks for your help anyway. I'm going to go and stick my head in a box for a while...

 

Rob

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.