Guneet Kaur
Guneet Kaur

Reputation: 544

omouseover not working for images at my machine though it works for online images

This is working in my browser:

<!DOCTYPE html>
<html>
<body>

<img src="http://nineplanets.org/planets.jpg" 
onmouseover="this.src='http://nineplanets.org/planetorder.JPG';"
onmouseout="this.src='http://nineplanets.org/planets.jpg';">
</img>

</body>
</html>

But this is not working:

<!DOCTYPE html>
<html>
<body>

<img src="C:\Users\user\Desktop\WE\Pics\milk.png"
onmouseover="this.src='C:\Users\user\Desktop\WE\Pics\butter.png';" 
onmouseout="this.src='C:\Users\user\Desktop\WE\Pics\milk.png';">
</img>

</body>
</html>

Please answer as soon as possible and path to my images is totally correct!!

Upvotes: 0

Views: 129

Answers (2)

Maximillian Laumeister
Maximillian Laumeister

Reputation: 20399

If you want to use paths pointing to your local hard drive, you will need to use the file protocol like this:

file:///c:/Users/user/Desktop/WE/Pics/milk.png

However, it's best practice to use relative URLs instead, for instance:

Pics/milk.png

will find the file milk.png in the Pics folder, where the Pics folder is alongside your HTML file.

Upvotes: 2

taxicala
taxicala

Reputation: 21789

You cannot use paths pointing to a local hard drive. That would be a major security issue. you will have to either mount a localhost server or try using the file:// protocol.

Upvotes: 1

Related Questions