Jump to content

advert popup window problem.


eddbrett

Recommended Posts

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>";

}
?>

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.