mcmuney Posted October 13, 2006 Share Posted October 13, 2006 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"elsealert("Nothing happened")[/code] Quote Link to comment Share on other sites More sharing options...
joshi_v Posted October 13, 2006 Share Posted October 13, 2006 HiTry 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! Quote Link to comment Share on other sites More sharing options...
mcmuney Posted November 10, 2006 Author Share Posted November 10, 2006 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.