# Calling java script from html to flash for swapping bg image

**URL:** <https://forum.kirupa.com/t/calling-java-script-from-html-to-flash-for-swapping-bg-image/153429>\
**Category:** Uncategorized\
**Created:** [July 1, 2005, 11:48am UTC](https://forum.kirupa.com/t/calling-java-script-from-html-to-flash-for-swapping-bg-image/153429 "2005-07-01T11:48:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harishcoorg](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@harishcoorg](https://forum.kirupa.com/u/harishcoorg)\
**Post date:** [July 1, 2005, 11:48am UTC](https://forum.kirupa.com/t/calling-java-script-from-html-to-flash-for-swapping-bg-image/153429/1 "2005-07-01T11:48:05Z")

</div>

Hi,  
I want to swap images throught javascript. It’s working.  
but my problem is I want to call that function from flash on press for my button  
this is the code I have used in html

[color=blue]\<script language=“JavaScript1.1”\>  
function swp(id)  
{ alert(“hi”);  
if (id==“img1”){  
document.getElementById(“img1”).src = “images/02.jpg”;  
document.getElementById(“img1”).id = “img2”;  
}  
else  
{  
document.getElementById(“img2”).src = “images/01.jpg”;  
document.getElementById(“img2”).id = “img1”;  
}  
}  
\</script\>[/color]  
[color=#0000ff][/color]  
[color=black]this is the code I have used in flash in my button but it’s not working[/color]

[color=blue]on (release) {  
getURL(“JavaScript:swp(id)”);  
}[/color]  
[color=#0000ff][/color]  
any one can help me please
