Make a webview size with the container window

590 views
Skip to first unread message

Ben Dilts

unread,
Mar 13, 2013, 4:53:49 PM3/13/13
to chromi...@chromium.org
Consider the following index.html:
<!DOCTYPE html>
<html>
<body>
<webview src="http://www.google.com" style="width:100%;height:100%;" autosize="on"></webview>
</body>
</html>

And the following background.js:
chrome.app.runtime.onLaunched.addListener(function(launchData) {
  chrome.app.window.create('index.html', {width: 800, height: 500}, function(win) {
    win.contentWindow.launchData = launchData;
  });
});

I just want a webview that resizes with the window. I've tried adding a Javascript file like this:

$(function() {
function resizeWebView() {
$('webview').get(0).width = $(window).width();
$('webview').get(0).height = $(window).height();
}
$(window).resize(resizeWebView);
resizeWebView();
});

This has no effect. What am I doing wrong?

Joe Marini

unread,
Mar 13, 2013, 5:50:20 PM3/13/13
to Ben Dilts, Chromium Apps
Ben - take off the autosize attribute.



--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.
 
 



--
Joe Marini
Developer Advocate / Chrome

Ben Dilts

unread,
Mar 13, 2013, 6:34:07 PM3/13/13
to chromi...@chromium.org, Ben Dilts
Hey Joe, as of the current Canary, turning off the autosize has no effect. The webview just sits at the initial size (which is 100% width and 100% height of the default window size) and never resizes.

Ben Dilts

unread,
Mar 13, 2013, 6:37:41 PM3/13/13
to chromi...@chromium.org, Ben Dilts
Huh. On the current stable build, that works, but on the Canary it's broken. Also, even on the stable branch, the webview only gets its size updated very infrequently, and often ends up several pixels (sometimes as much as 20-40px) off of the actual size of the containing window.

Ben Dilts

unread,
Mar 13, 2013, 6:39:31 PM3/13/13
to chromi...@chromium.org, Ben Dilts
Ah, got it. The width and height both get updated correctly if I resize the frame horizontally. If I resize the frame vertically, nothing happens whatsoever.

Joe Marini

unread,
Mar 13, 2013, 6:56:09 PM3/13/13
to Ben Dilts, Chromium Apps
Hmm. Let me take a look.

Joe Marini

unread,
Mar 13, 2013, 6:56:26 PM3/13/13
to Ben Dilts, Chromium Apps
OK.

Reply all
Reply to author
Forward
0 new messages