Hi,
I am new to this forum. Could you please help me out in fixing this issue. The problem is in my page the images will be getting changed randomly but when i click on a link button a popup window with window.open will navigate a user to another page but in the background the page with random image gets disappeared. Is it possible to make the image appear in the page. Please find the code below. Could you please let me know should i need to add a event listener if so then which event listener will work on click of link button and popup window is being displayed so that the image in the background will be displayed.
Thanks,Code:var num; var temp=0; var speed=5000; /* this is set for 5 seconds, edit value to suit requirements */ var preloads=[]; /* add any number of images here */ preload( 'Images/Stock/1.jpg', 'Images/Stock/2.jpg', 'Images/Stock/3.jpg', 'Images/Stock/4.jpg', 'Images/Stock/5.jpg', 'Images/Stock/6.jpg', 'Images/Stock/7.jpg', 'Images/Stock/8.jpg' ); function preload(){ for(var c=0;c<arguments.length;c++) { preloads[preloads.length]=new Image(); preloads[preloads.length-1].src=arguments[c]; } } function rotateImages() { num=Math.floor(Math.random()*preloads.length); if(num==temp){ rotateImages(); } else { document.getElementById("pagemiddlecenter").style.backgroundImage = 'url(' + preloads[num].src + ')'; temp=num; setTimeout(function(){rotateImages()},speed); } } if(window.addEventListener){ window.addEventListener('load',rotateImages,false); } else { if(window.attachEvent){ window.attachEvent('onload',rotateImages); }
Deepak



Reply With Quote
