Detect if viewport is onscreen?

Is there any way to be able to query the GPU to tell me if my viewport in my webpage is currently on screen or not? For example, if I had a 3d scene rendering in a canvas in an iframe, is there a way to query the hardware (within my iframe and only the pixels or verts in the viewport) to say if I am on screen or scrolled off screen? I thought that the hardware would be smart enough to only render what is currently on screen and Im currently trying to come up with some way of possibly doing this in a vertex shader. Any possible ideas? Is this even possible? Thanks!