Modified show_hide_box function (
additions in red):
Code:
function show_hide_box(an, width, height, borderStyle) {
var href = an.href;
var boxdiv = document.getElementById(href);
if (boxdiv != null) {
if (boxdiv.style.display=='none') {
move_box(an, boxdiv);
boxdiv.style.display='block';
} else
boxdiv.style.display='none';
return false;
}
boxdiv = document.createElement('div');
boxdiv.setAttribute('id', href);
boxdiv.style.display = 'block';
boxdiv.style.position = 'absolute';
boxdiv.style.width = width + 'px';
boxdiv.style.height = height + 'px';
boxdiv.style.border = borderStyle;
boxdiv.style.backgroundColor = '#fff';
var close_btn = document.createElement("div");
close_btn.className = "box_close_btn";
close_btn.pid = href;
close_btn.onclick = function()
{
show_hide_box({href:this.pid});
}
boxdiv.appendChild(close_btn);
var contents = document.createElement('iframe');
contents.scrolling = 'no';
contents.frameBorder = '0';
contents.style.width = width + 'px';
contents.style.height = height + 'px';
contents.src = href;
boxdiv.appendChild(contents);
document.body.appendChild(boxdiv);
move_box(an, boxdiv);
return false;
}
Use CSS to assign your close button image:
Code:
<style type="text/css">
.box_close_btn
{
cursor: pointer;
position: absolute;
right: 0px;
top: 0px;
width: 20px;
height: 20px;
background: #ff0000; /*Put image here.*/
}
</style>