Msc Final Project

Mouseover to set the image as background (js)

I was trapped in this tiny little bug for several hours: a href=”#” is a must or it will refresh the whole site, then you will never change the background image, never!

<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<style>/*this should be an independent CSS*/

function basename(url){ var loc = url.lastIndexOf("/")+1;//get the direct name of image return url.substr(loc); } function changepic(obj){"url('images/"+basename(obj.src)+"')"; } function returnpic(obj){"#b8c2f8";//if mouseout then return to its normal bgcolor } </body> </html>  

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s