Advanced Search

Results 1 to 3 of 3

Thread: html2canvas - take screenshot of a visible div and of a div with "display: none;"

  1. #1
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default html2canvas - take screenshot of a visible div and of a div with "display: none;"

    Hello guys,

    I need some advice about a issue I'm dealing with for the past 2 days

    I trying to take a screenshot of a specific div which holds a couple of images that change every refresh.
    I've managed to do that, using the following script - html2canvas (link: http://html2canvas.hertzen.com/)

    Now, the script works just perfect until a specific point...

    I have 2 div elements called "Tab_1" and "Tab_2", and both of them are been displayed using another .js script (for creating tabs).
    Actualy, the tabs are created using the CSS-display options (the active one has "display: block;" - and the inactive one has "display: none;")

    This is where the html2canvas script kinda fails....
    It will take a screenshot of the images under the <div> tag which has the attribute "display: block" (the active tab) but it will not take a screenshot of the image under the <div> tag which has the attribute "display: none" (the inactive tab)

    Basically this is my issue...

    I want to call the function and be able to take the screenshot of both tabs (the active and the inactive)

    Below is the script i'm working one:
    Code:
    function saveModel(usermamePic, firstPic, secondPic) {
      var first_elm = document.getElementById(firstPic);
      var second_elm = document.getElementById(secondPic);
    
      html2canvas([first_elm],{
         onrendered: function(canvas) {
    	var dataUrl_tabActive = canvas.toDataURL();
    		$.post('phpinclude/save.php', 
                             {'encoded_img': ''+ dataUrl_tabActive +'',
    			   'username_img': ''+ usermamePic +'',
    			   'location_img': 'tabActive'
    			  }, 
                               function(img) {
    				alert(img);
    				html2canvas([second_elm],{
    				   onrendered: function(canvas) {
    				      var dataUrl_tabInactive = canvas.toDataURL();
    				      $.post('phpinclude/model_save.php', 
                                                   {'encoded_img': ''+ dataUrl_tabInactive +'',
    						'username_img': ''+ usermamePic +'',
                                                    'location_img': 'tabInactive'
                                }, 
                                function(img) {
                                  alert(img);
                                });
    			}
    		 });
              });
          }
      });	
    }
    + the html2canvas.js from the webpage shown above.

    Any help will be appreciated!

    My best regards,
    Michael

  2. #2
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It seems that nobody has any clue on how to fix this ?
    Or any ideas on this subject ?

    Hopefully I'm wrong about this

    My best regards,
    Michael

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,623
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by mihailmrom View Post
    It will take a screenshot of the images under the <div> tag which has the attribute "display: block" (the active tab) but it will not take a screenshot of the image under the <div> tag which has the attribute "display: none" (the inactive tab)
    Sure it will. But keep in mind that it will be a blank image.

    display: none means just that: "not displayed." If you want to see that div (for any reason), you'll need to change that (e.g., to display: block) first.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

Similar Threads

  1. IE setting to allow "Magnify" sctipt's Zoom-In cursor to display?
    By BobBerg in forum Dynamic Drive scripts help
    Replies: 8
    Last Post: 09-27-2012, 12:46 PM
  2. Replies: 0
    Last Post: 04-11-2009, 08:48 AM
  3. "alpha" vs "visible"
    By evan in forum Flash
    Replies: 2
    Last Post: 07-30-2008, 04:16 PM
  4. RSS Display Boxes: can't get past "Initializing RSS Display Box..."
    By jancohen in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-26-2007, 06:14 PM
  5. style.display=="none") ? "block" : "none";
    By lucavizzi in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 10-17-2007, 01:52 PM

Bookmarks

Posting Permissions

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