/    Sign up×
Community /Pin to ProfileBookmark

need help with background image in javascript!

so this is a script with a layer behind it (container) and a layer on top (content) that scrolls via buttons below it.. i’m sure you have seen some of these before. anyways.. i can change the colour of the background to show through… but i cant put an image in its place.. it is crucial that i have an image behind the text!! am i just totally missing it? see if you can figure it out…


————

<html><body>
<script language=”JavaScript1.2″>

/******************************************
*
Scrollable content script II- © Dynamic Drive ([url]www.dynamicdrive.com[/url])
* Visit [url]http://www.dynamicdrive.com/[/url] for full source code
*
This notice must stay intact for use
**
****************************************/

iens6=document.all||document.getElementById
ns4=document.layers

//specify speed of scroll (greater=faster)
var speed=5

if (iens6){
document.write(‘<div id=”container” style=”position:relative;width:500;height:300;border:1px solid black;overflow:hidden;background:black”>’)
document.write(‘<div id=”content” style=”position:absolute;width:500;left:0;top:0″>’)
}
</script>

<ilayer name=”nscontainer” width=500 height=300 clip=”0,0,500,300″>
<layer name=”nscontent” width=500 height=300 visibility=hidden>
<!–INSERT CONTENT HERE–>
<p><font color=”#ffffff”>
CONTENT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT
<p>
TEXT</font>

<!–END CONTENT–>

</layer>
</ilayer>

<script language=”JavaScript1.2″>
if (iens6)
document.write(‘</div></div>’)
</script>

<table width=”500px”><td><p align=”right”>
<a href=”#” onMouseover=”moveup()” onMouseout=”clearTimeout(moveupvar)”><img src=”up.gif” border=0></a> <a href=”#” onMouseover=”movedown()” onMouseout=”clearTimeout(movedownvar)”><img src=”down.gif” border=0></a></p></td>
</table>

<script language=”JavaScript1.2″>
if (iens6){
var crossobj=document.getElementById? document.getElementById(“content”) : document.all.content
var contentheight=crossobj.offsetHeight
}
else if (ns4){
var crossobj=document.nscontainer.document.nscontent
var contentheight=crossobj.clip.height
}

function movedown(){
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (ns4&&crossobj.top>=(contentheight*
(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout(“movedown()”,20)
}

function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout(“moveup()”,20)

}

function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility=”show”
}
window.onload=getcontent_height
</script>
</body></html>


———————-

if (iens6){
document.write(‘<div id=”container” style=”position:relative;width:500;height:300;border:1px solid black;overflow:hidden;background:black”>’)

that is the line of text that i altered to make the background black.. but there needs to be an image there instead..

help??

THANKS!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cyberadeFeb 19.2003 — Try substituting the word black with url(imagename).

i.e.

if (iens6){

document.write('<div id="container" style="position:relative;width:500;height:300;border:1px solid black;overflow:hidden;background:url(images/your_image)">')
Copy linkTweet thisAlerts:
@callxmexmorbidauthorFeb 19.2003 — that workded!

thanks!!
×

Success!

Help @callxmexmorbid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...