We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23849
    • 223 Posts
    Hi All,

    I’ve been trying to add a print button next to the close button in lightbox but I’m having some trouble. Here’s what I’ve tried so far:

    In lightbox_lang_en.js I’ve added this:
    var fileBottomNavPrintImage = "assets/snippets/maxigallery/lightboxv2/images/printlabel.gif";


    In lightbox.js I’ve added this:
    //Added By N Hoag for Printing
    		var objBottomNavPrintLink = document.createElement("a");
    		objBottomNavPrintLink.setAttribute('id','bottomNavPrint');
    		objBottomNavPrintLink.setAttribute('href','#');
    		objBottomNavPrintLink.onclick = window.print();
    		objBottomNav.appendChild(objBottomNavPrintLink);
    		
    		//Added By N Hoag for Printing
    		var objBottomNavPrintImage = document.createElement("img");
    		objBottomNavPrintImage.setAttribute('src', fileBottomNavPrintImage);
    		objBottomNavPrintImage.appendChild(objBottomNavPrintImage);
    		
    		var objBottomNavCloseLink = document.createElement("a");
    		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
    		objBottomNavCloseLink.setAttribute('href','#');
    		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
    		objBottomNav.appendChild(objBottomNavCloseLink);
    	
    		var objBottomNavCloseImage = document.createElement("img");
    		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
    		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
    


    I’ve also created a print stylesheet for when you click the print button. This doesn’t work but I’m not sure what else I need to add. Any thought/tips would be much appreciated!

      Nick Hoag
      Creative Partner
      The FutureForward

      http://thefutureforward.com
      • 7923
      • 4,213 Posts
      So what’s the problem currently? Also, if you put a sample page online, I / we could give better help.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 23849
        • 223 Posts
        Hi Doze,

        Here’s a link to a sample page - http://edgeworksdisplay.com/tester.html

        Currently it brings up the print dialog box as soon as I load the page with this code in lightbox.js:

        //Added By N Hoag for Printing
        		var objBottomNavPrintLink = document.createElement("a");
        		objBottomNavPrintLink.setAttribute('id','bottomNavPrint');
        		objBottomNavPrintLink.setAttribute('href','#');
        		objBottomNavPrintLink.onclick = window.print();
        		objBottomNav.appendChild(objBottomNavPrintLink);
        		
        		//Added By N Hoag for Printing
        		var objBottomNavPrintImage = document.createElement("img");
        		objBottomNavPrintImage.setAttribute('src', fileBottomNavPrintImage);
        		objBottomNavPrintImage.appendChild(objBottomNavPrintImage);
        		
        		var objBottomNavCloseLink = document.createElement("a");
        		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
        		objBottomNavCloseLink.setAttribute('href','#');
        		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
        		objBottomNav.appendChild(objBottomNavCloseLink);
        	
        		var objBottomNavCloseImage = document.createElement("img");
        		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
        		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
        


        Let me know if you need any more details!
          Nick Hoag
          Creative Partner
          The FutureForward

          http://thefutureforward.com
          • 7923
          • 4,213 Posts
          First you need to change this:
          objBottomNavPrintLink.onclick = window.print();

          to this:
          objBottomNavPrintLink.setAttribute('onclick','window.print();');


          And check what happens then..


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 23849
            • 223 Posts
            Hi Doze,

            That change is in place and the print dialog no longer loads when you load the page - http://edgeworksdisplay.com/tester

            Now the lightbox effect doesn’t work. Any ideas?
              Nick Hoag
              Creative Partner
              The FutureForward

              http://thefutureforward.com
              • 7923
              • 4,213 Posts
              Change:
              objBottomNavPrintImage.appendChild(objBottomNavPrintImage);


              to:
              objBottomNavPrintLink.appendChild(objBottomNavPrintImage);


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 23849
                • 223 Posts
                That was it Doze, totally missed that spot in the code. Thanks SO much!
                  Nick Hoag
                  Creative Partner
                  The FutureForward

                  http://thefutureforward.com
                  • 35744
                  • 1 Posts
                  Hell, I was wondering if you can solve my problem... I want the print button function but I have the lightbox working with rollovers... Please take a look at what I have done so far: http://www.mondayre.com/availabilities/NY/ny.html... I have the rollover working with the lightbox... I now need to implement the print button but everything I have tried does not work. Please help. Thank you.
                    • 35019
                    • 1 Posts
                    A couple of years ago I’ve modified Lightbox v2.04 and added a Print-button.
                    Now, I still receive questions and bug reports about that particular script, so today I decided to update the script using Lightbox v2.05.
                    You can view a demo at http://sandbox.tse-webdesign.be/lightbox-print/

                    You can download the script at http://sandbox.tse-webdesign.be/lightbox-print/lightbox-print.zip

                    Best regards,
                    Vincent