Ok guys, I've looked everywhere but I'm absolutely stuck.
If I use this:
<script language="JavaScript">
<!--
function setBlock(block, chimage, bgimage, chlink) {
eval("top." + block + ".style.backgroundImage='" + chimage + "'");
}
setBlock("a1", "man.gif", "beach.jpg", "link");
-->
</script>
- <script language="JavaScript">
- <!--
- function setBlock(block, chimage, bgimage, chlink) {
- eval("top." + block + ".style.backgroundImage='" + chimage + "'");
- }
- setBlock("a1", "man.gif", "beach.jpg", "link");
- -->
- </script>
it gives me 'invalid argument' for the eval function. However, if I remove the ' ' around chimage, like so
<script language="JavaScript">
<!--
function setBlock(block, chimage, bgimage, chlink) {
eval("top." + block + ".style.backgroundImage=" + chimage);
}
setBlock("a1", "man.gif", "beach.jpg", "link");
-->
</script>
- <script language="JavaScript">
- <!--
- function setBlock(block, chimage, bgimage, chlink) {
- eval("top." + block + ".style.backgroundImage=" + chimage);
- }
- setBlock("a1", "man.gif", "beach.jpg", "link");
- -->
- </script>
It gives me "'man' is undefined".
How can I write this to put the string
chimage as the backgroundimage without messing up the eval function?
Extra notes:
This code is within an iframe, and the block 'a1' is a div outside of the iframe.
bgimage and chlink will be used later, but are not used for the purpose of this specific question. Obviously, once I do use them I'll use the same hints I get here