PDA

View Full Version : Left-Right Curtain Script - Using an image



Dan71121
01-24-2006, 12:01 PM
Left-Right Curtain Script
http://www.dynamicdrive.com/dynamicindex3/document6.htm

Hello All - this script is working fine. Upon entering a page, it looks like a curtain is opening from the center and allows you to change the color of the "curtain". Question: is it possible for this script to use an image (.jpg, .gif) for the "curtain color" as opposed to just specifying a color in <style> (red, blue, etc).

I have a .gif of a closed curtain and would like to use that as opposed to a plain color. Thanks for your help! - Dan

Below is the two parts of the script:

Part 1:
<style>
<!--
.intro{
position:absolute;
left:0;
top:0;
layer-background-color:red;
background-color:red;
border:0.1px solid red;
z-index:9;
}
-->
</style>

Part 2:
<div id="i1" class="intro"></div><div id="i2" class="intro"></div>
<script language="JavaScript1.2">

/*
Left-Right Curtain Script- Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more free DHTML scripts, and TOS,
visit http://dynamicdrive.com
*/

var ns4=document.layers?1:0
var ie4=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

var speed=20
var temp=new Array()
var temp2=new Array()
if (ns4){
for (i=1;i<=2;i++){
temp[i]=eval("document.i"+i+".clip")
temp2[i]=eval("document.i"+i)
temp[i].width=window.innerWidth/2
temp[i].height=window.innerHeight
temp2[i].left=(i-1)*temp[i].width
}
}
else if (ie4||ns6){
var clipright=ns6?window.innerWidth/2*0.98:document.body.clientWidth/2,clipleft=0
for (i=1;i<=2;i++){
temp[i]=ns6?document.getElementById("i"+i).style:eval("document.all.i"+i+".style")
temp[i].width=ns6?window.innerWidth/2*0.98:document.body.clientWidth/2
temp[i].height=ns6?window.innerHeight-1: document.body.offsetHeight
temp[i].left=(i-1)*parseInt(temp[i].width)
}
}


function openit(){
window.scrollTo(0,0)
if (ns4){
temp[1].right-=speed
temp[2].left+=speed
if (temp[2].left>window.innerWidth/2)
clearInterval(stopit)
}
else if (ie4||ns6){
clipright-=speed
temp[1].clip="rect(0 "+clipright+" auto 0)"
clipleft+=speed
temp[2].clip="rect(0 auto auto "+clipleft+")"
if (clipright<=0){
clearInterval(stopit)
if (ns6){
temp[1].display="none"
temp[2].display="none"
}
}
}
}

function gogo(){
stopit=setInterval("openit()",100)
}
gogo()

</script>

ddadmin
01-24-2006, 01:39 PM
Sure, though the image would have to be a background image, either tiling or no tile. Just change the CSS code to:


<style type="text/css">
<!--
.intro{
position:absolute;
left:0;
top:0;
background: url("http://www.sxc.hu/pic/m/b/bo/bosela/452737_60254098.jpg") top left repeat;
z-index:9;
}
-->
</style>

I'm using an arbitrary background on the web to show this. In this case, the image tiles to fill the entire curtain.