100vh and Android Chrome

While working to my our product work with mobile devices, I encountered this issue with Chrome for Android.

It seems that setting an element height to 100vh will include the height of the Chrome Address bar and tabs. This is designed so that when user scrolls down the address bar and tabs will go away to show the web page using the whole screen(except the notification shade, of course).

Where as in Chrome for desktop, 100vh only includes the height of the viewing area below the address bar.

Because of this feature, website that looks correctly in desktop may not work correctly in mobile, need to keep this in mind. Use Android Chrome remote debugging feature to debug the website in Chrome for Android.

 

Open a popup window while sending post data

It’s actually very simple. It’s possible to create a form element and set the target to _blank so that upon submission the target will be opened in a new browser window/tab.
Use hidden input elements to pass data to the target URL.

<form action=”<target URL>” method=”POST” target=”_blank”>
  <input type=”hidden” name=”Name” value=”Wayne”>
  <input type=”submit” value=”Click here to open the window”>
</form>

If  you don’t want a button, use CSS to style the submit button to make it look like a hyperlink.

If you use ASP.NET or SharePoint the framework may complain that there should be only one form tag in the page. In that case use Javascript to construct the form on the fly when the link is clicked, then get rid of the form element after the window is open.

function openWindow()
{
var mapForm = document.createElement(“form”);
mapForm.style.display=”none”;
mapForm.target = “Map”;
mapForm.method = “POST”; // or “post” if appropriate
mapForm.action = “http://localhost:55079/Default.aspx”;

var mapInput = document.createElement(“input”);
mapInput.type = “text”;
mapInput.name = “test”;
mapInput.value = “Test Data”;
mapForm.appendChild(mapInput);

document.body.appendChild(mapForm);

map = window.open(“”, “Map”, “status=0,title=0,height=600,width=800”);

if (map) {
mapForm.submit();
}
//delete the form element
mapForm.parentNode.removeChild(mapForm);
}

<a href=”#” onclick=”javascript:openWindow();”>Click here to open window</a>