Jump to content

Archived

This topic is now archived and is closed to further replies.

mcmuney

Php/Javascript

Recommended Posts

I need the "window.location" on the javascript below to be, how would this be incorporated? Basically, on click on an image thumbnail, I want an alert to popup with options "Continue" and "Cancel". If Cancel then the obvious happens, but on Continue, it opens up this window: [code]<a href="" onClick="javascript:window.open('view_full_image.php?imgid=<?=$res[$img][sci_id]?>','','top=50,left=50,width=600,height=600,scrollbars=yes') ; return false;" >[/code]

[code]
var answer = Confirm: ("Are you sure you want to continue?")
if (answer)
window.location = "http://www.videogamedeals.com"
else
alert("Nothing happened")
[/code]

Share this post


Link to post
Share on other sites
Hi

Try this.

Instead of directly opening a window when u click on the link, pass all the variables u need to pass to the new window through javascript function.like,

<a href="" onClick = "return window_open(<?=$res[$img][sci_id]?>)";>

Write a javascript function to perform the required actions before opening a new window.

function window_open(passed_value)
{
if(confirm("Are you sure you want to continue?"))
{
window.open('view_full_image.php?imgid=passed_value','','top=50,left=50,width=600,height=600,scrollbars=yes') ;
}
else
{
alert("Nothing happened");

}
}


Hope it will helps you!

Share this post


Link to post
Share on other sites
Hey, I've been using the above, but just noticed a bug. When there's only 1 image, this works perfectly, but when there are multiple images, it always displays the same image onclick. It appears that the "sci_id" is passing for 1 image only. Any ideas?

PS. Also, onclick, when it opens the image in the popup window, it refreshes the main page back to the homepage, why does that happen?

Share this post


Link to post
Share on other sites

×

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.