PDA

View Full Version : set image as background??


doubleT
07-03-2002, 06:21 AM
Hey yall!

I need a script that it set the image that you want to set when you located that file in your computer (or the url)

by using the button "brose" then popup a window to locate image

and then it set it as background.

Any one know how to do??

THx all

joh6nn
07-03-2002, 12:04 PM
<FORM NAME="formName">
<INPUT TYPE="FILE" NAME="file">
<INPUT TYPE="BUTTON" OnClick="bg();" VALUE="click click">
</FORM>
<SCRIPT>
function bg() {
var theForm = document.formName;
document.body.style.backgroundImage = theForm.file.value;
}
</SCRIPT>

doubleT
07-04-2002, 02:43 AM
I try the above javascript, and it doesn't work..

Then try put the <script> into the <head><script>dfskajfd </script></head> then the form.. And it still doesn't work!

Any can help me out?? IT popups an error window with Yes or No button..

doubleT
07-04-2002, 03:14 AM
Hey.. This time I try the codes.. there is no error but it won't set background image for me. it only set it to white colors..
<FORM NAME="hh">
<INPUT TYPE="file" NAME="ff">
<INPUT TYPE="button" onclick="bg();" VALUE="Select">
</FORM>
<SCRIPT>
function bg() {
var theForm = document.hh;
document.body.style.background="bg('theForm.ff.value') fixed"
}
</SCRIPT>

If i use
document.body.style.backgroundImage="bg('theForm.ff.value') fixed"

this will give me error..

Can any one help me??