Jump to content

Php/Javascript


mcmuney

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]
Link to comment
https://forums.phpfreaks.com/topic/23819-phpjavascript/
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!
Link to comment
https://forums.phpfreaks.com/topic/23819-phpjavascript/#findComment-108204
Share on other sites

  • 4 weeks later...
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?
Link to comment
https://forums.phpfreaks.com/topic/23819-phpjavascript/#findComment-122572
Share on other sites

Archived

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

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