Jump to content


Photo

Php/Javascript


  • Please log in to reply
2 replies to this topic

#1 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 13 October 2006 - 03:47 AM

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

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


#2 joshi_v

joshi_v
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 13 October 2006 - 06:41 AM

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!

#3 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 10 November 2006 - 08:32 AM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users