I’m making a new web site ([url]http://www.i-backgrounds.com
I’ve managed to hack a script together that opens and closes the window just as I wanted, but so far I have to hard code the texture into the script (in the head section of the page) to make it work. That means I can only use it for one link on the page. What I need is way to code the background texture I want displayed in the pop up window into the onMouseover event in the page link and have the script in the head section pick up that texture to use as the background image of the pop up window — that way I can display a different texture for each link, reflecting the type of texture featured on the page the link leads to.
Here’s the code from the HEAD section:
<script type=”text/JavaScript”>
function open_new_window()
{
new_window = open(“”,”hoverwindow”,”width=300,height=200,left=10,top=10″);
new_window.document.open();
new_window.document.write(“<html><.title>Sample Texture</title>”);
new_window.document.write(“<body background=’background_images/Texture01.jpg’>”);
new_window.document.write(“This is a sample of the texture style on this page. “);
new_window.document.write(“It is available in six different colors.”);
new_window.document.write(“</body></html>”);
new_window.document.close();
}
function close_window()
{
new_window.close();
}
</script>
Here’s how I’m coding the link:
<a href=”textured_backgrounds_1.shtml”
onMouseOver=”open_new_window();”
onMouseOut=”close_window()”>Textured Background Images Page 1</a>
The script works beautifully like this. I tried changing this line:
new_window.document.write(“<body background=’background_images/Texture01.jpg’>”);
…to this:
new_window.document.write(“<body background=’+image+’>”);
…and tried all sorts of ways to pass the background image I wanted to use from the link into that +image+ part, but after hours and hours of frustration I thought I’d beg for help!
Maybe I’m not even going about it in the right way, I know just enough about JavaScript to frustrate myself. What I’ve basically done so far is to take pieces of different JavaScript code examples and piece them together to get this far. What I can’t find is how to pass the variable I need from the onMouseover event to the script in the HEAD section. Point being, if anyone has a solution, please be specific as to exactly what I need to do and you’ll be my hero for the month!