Link to home
Start Free TrialLog in
Avatar of jbajaj
jbajaj

asked on

change background image for a button

I have 2 frames for my page upper_frame.html and lower_frame.html

in lower_frame.html I have a button with background as back.bmp , clicking on which I change the html content in upper_frame.html. I want to add code to change the background of the button after it is clicked to front.bmp.

here is my cuurent code

<html>
<head>

<SCRIPT language="JavaScript">

function change_overview()
{
parent.upper_frame.location="demo.html";
}
</script>
</head>

<body>

<button name="overview" style="background-image:url(back.bmp)" onclick="javascript:change_overview()"><font color="#FFFFFF">Product Overview</font>
</button>
</body>
</html>
Avatar of Pratima
Pratima
Flag of India image

<button name="overview" style="background-image:url(back.bmp)" onclick="javascript:change_overview()" id="btnOverview" >
function change_overview()
{
parent.upper_frame.location="demo.html";
var elm = document.GetElementById("btnOverview");
elm.style.background-image = "url(front.bmp)"
}
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The comment http:#20175514 contains a commen wrong assumption about syntax of style attributes in JavaScript. Therefore I would not add that comment to PAQ to increase the confusion.
My proposal:

Accept:  Zvonko {http:#20175714}


Forced accept.

Computer101
EE Admin