SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    0 Post(s)
    0 Thread(s)

    printing an image using Javascript

    Hello fellow scripters,

    i know that someone here has the answers that i am looking for. i currently have my imnages set up to popup in a new window when the mouse cursor is placed over it with a print button. here is what i would like to do. to remove the mouseover popup command and have a button to print this image without the popup window. below is the code for the popup window minuse the script header and footer

    // Set the horizontal and vertical position for the popup

    PositionLeft = 380;
    PositionTop = 180;

    // Set these value approximately 20 pixels greater than the
    // size of the largest image to be used (needed for Netscape)

    defaultWidth = 250;
    defaultHeight = 490;

    // Set autoclose true to have the window close automatically
    // Set autoclose false to allow multiple popup windows

    var AutoClose = false;

    // Do not edit below this line...
    // ================================
    if (parseInt(navigator.appVersion.charAt(0))>=4)
    var isNN=(navigator.appName=="Netscape")?1:0;
    var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}

    var optNN='scrollbars=no, width=' + defaultWidth + ',height=' + defaultHeight + ',left=' + PositionLeft + ',top=' + PositionTop;
    var optIE='scrollbars=no, width=250, height=490, left=' + PositionLeft + ',top=' + PositionTop;

    function popImage(imageURL,imageTitle)
    if (isNN){'about:blank', '', optNN);}
    if (isIE){'about:blank', '', optIE);}

    with (imgWin.document){
    writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,320);');
    writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
    writeln('function doTitle(){document.title="' + imageTitle + '";}');writeln('</sc'+'ript>');
    if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
    else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
    writeln('<input class="noPrint" type="button" value="Print Current Love Is Panel " onclick="window.print()"><img name="loveisPanel" src=' + imageURL + ' style="display:block"></body></html>');

    below is where i call the popup window:

    <a href="javascript: void(0)" onmouseover="popImage(paneldir + panelsubdir + panelyear + '/' + panelmonth + '/' + panelname + panelext, panelmonth + ' ' + panelday + ' ' + panelyear)">

    i need this in a <input> button with out the popup window function, also if possible the above also with a save button where you can click on the button and save the image. just like the print button, now a save button also...

    thanks for your help and patience.....
    Last edited by jbetts1967; Sep 11, 2008 at 16:02. Reason: correct some spelling


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts