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