GithubHelp home page GithubHelp logo

Comments (6)

mrcoles avatar mrcoles commented on July 19, 2024

My first guess was that it might be caused by the document starting with <?xml version='1.0' encoding='UTF-8'?>, so I copied the page locally and tried again, but document.width worked.

The CSS link was broken though, so I fixed the URL, but it still worked.

The main difference I see between my local file and the hosted one is that the hosted one served as type "application/xhtml+xml".

Various hacky backup widths could be tried out:

// get document width
var width = document.width;

if (width === undefined) {
    // if document width fails, e.g., this page http://jblevins.org/projects/markdown-mode/
    // then find the biggest element available to grab width
    var widthElt = (document.getElementsByTagName('html')[0] ||
        document.getElementsByTagName('body')[0] ||
        document.querySelector('*'));

    // use widthElt’s width or worst-case fallback to the window
    width = widthElt ? widthElt.offsetWidth : window.innerWidth;
}

from full-page-screen-capture-chrome-extension.

terrycojones avatar terrycojones commented on July 19, 2024

Hi... interesting!

This might be relevant, though it's from a while ago http://www.sencha.com/forum/showthread.php?243424-ExtJS-3.4-bugs-inside-xhtml-document

This page https://en.wikipedia.org/wiki/Quirks_mode indicates that Chrome should be in Standards mode, and that is the case:

document.compatMode
"CSS1Compat"

I read stuff elsewhere (about zooming & scaling) that adds an SVG element to the document, gets its width, and removes it. That might be another way to get a value.

from full-page-screen-capture-chrome-extension.

szuranski avatar szuranski commented on July 19, 2024

Chrome 31.0.1650.48 Win7

I installed the extension a few weeks ago and used it without problems. Starting today I am experiencing the same behavior as described above except it happens on all pages.

I replaced with document.width & height with document.body.clientWidth & clientHeight and it appears to be working. Do these properties not return the values needed? It seems to be working but I can't compare it to what was being returned using the former properties.

I get the same behavior here too.
http://jsfiddle.net/szuranski/t24R9/17/

from full-page-screen-capture-chrome-extension.

mrcoles avatar mrcoles commented on July 19, 2024

What do you guys think of this approach?

I adapted it from a suggestion on this SO page: http://stackoverflow.com/questions/5484578/how-to-get-document-height-and-width-without-using-jquery

from full-page-screen-capture-chrome-extension.

szuranski avatar szuranski commented on July 19, 2024

I have used a similar technique when needing to find the max size of the window. It is working with the few captures I have done so far.

from full-page-screen-capture-chrome-extension.

terrycojones avatar terrycojones commented on July 19, 2024

Hey Peter. I just ran into this issue again, as have some people that are using the same code, and the fix you came up with (nice) seems to fix it. We're doing some more testing now.

from full-page-screen-capture-chrome-extension.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.