eddbrett Posted January 16, 2008 Share Posted January 16, 2008 Basically I have the following code, which displays a series of adverts on a page and links an image to a url. The problem I am having is that when an advert is clicked and the new window is displayed, upon closing the window, all adverts still link to the original url. Wondering if there’s a way round this without refreshing the page, I know it’s a JavaScript issue, as it worked fine before I decided to introduce new windows. Any help is much appreciated, thanks. <? // Edit this number to however many links you want displaying $num_displayed = 3 ; // Select random rows from the database $result = mysql_query ("SELECT * FROM links ORDER BY RAND() LIMIT $num_displayed"); // For all the rows that you selected while ($row = mysql_fetch_array($result)) { // Display them to the screen... echo "<script>function my_win() { window.open('http://" . $row["link"] . "','mywindow','width=500,height=500,toolbar=no,location=yes,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes'); }; </script> <a href=javascript:my_win()> <img src=\" images/" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\" width=\"170\" height=\"170\"\"> <br> </a>"; } ?> Quote Link to comment Share on other sites More sharing options...
taith Posted January 16, 2008 Share Posted January 16, 2008 hate to be a stick in the mud... but... if your looping to output a javascript function... when it repeats...(the second+ time) it'll probably crash on most browsers... fix... make your javascript popups inline should fix your problems... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.