Open image in popup while click on text

images php coding issues or problems here.

Moderators: macek, egami, gesf

phpkiller
New php-forum User
New php-forum User
Posts: 31
Joined: Thu Jun 28, 2012 2:11 pm

Open image in popup while click on text

Postby phpkiller » Wed Jul 03, 2013 5:01 am

First Put This code in your page:
<script language="javaScript" type="text/javascript">
function runme(priceval){
newprice1 = 0;
if(document.getElementById("option_oc_range").value != ''){
newprice1 = eval(parseInt(priceval)+parseInt(document.getElementById("option_oc_range").value));
} else {
newprice1 = parseInt(priceval);
}
document.getElementById("amount").value = '$' + newprice1;
}
</script>
<script language="javaScript" type="text/javascript">

var newwindow = '';
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus();
} else {
newwindow=window.open(url,'htmlname','width=700,height=650,resizable=1, left=250');}
}

function tidy() {
if (newwindow.location && !newwindow.closed) {
newwindow.close();
}
}
</script>

Now put This code in your HTML text:
<a href="javascript:popitup('images/myimage.jpg')">night vision lighting comparison chart</a>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Open image in popup while click on text

Postby johnj » Mon Jul 08, 2013 2:56 am

So, what is the error that you are getting while opening the image in a popup?

techbatfly
New php-forum User
New php-forum User
Posts: 32
Joined: Mon Feb 16, 2015 3:23 am
Contact:

Re: Open image in popup while click on text

Postby techbatfly » Fri Mar 20, 2015 5:41 am

First put this script in your head tag

Code: Select all

 <script language='javascript'>
            function display(myimage, w, h) {
                html = "<html><head><title>photo</title>" +
                        "</head><body leftmargin=0 "
                        + "marginwidth=0 topmargin=0 marginheight=0><center>"
                        + "<img src='" + myimage + "' border=0 name=image "
                        + "onload='window.resizeTo(document.image.width,document.image.height)'>"
                        + "</center>"
                        + "</body></html>";
                var left = (screen.width / 2) - (w / 2);
                var top = (screen.height / 2) - (h / 2);
                popup = window.open('', 'image', 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1 width=' + w + ', height=' + h + ', top=' + top + ', left=' + left + '');
                popup.document.open();
                popup.document.write(html);
                popup.document.close()
            }
            ;
          </script>

after that paste this line in your body tag

Code: Select all

 
 <!-- you can manage the window height and width by 2nd and 3rd parameter of display function. -->
 <a href="javascript:display('upload/1802_Hydrangeas.jpg',1000,1000)">Javascript HowTo 1</a
 


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest

cron