Android doesn't respect meta tag removal?

I created a sample script to add and remove meta tags from the head. But Android 2.2 does not seem to respect its removal. However, he really respects adding a meta tag to a click, for example. How can I make him respect the removal of the tag and return to the default viewport through javascript?

<script type="text/javascript"> $(document).ready(function(){ function initMeta(){ var headID = document.getElementsByTagName("head")[0]; var metaNode = document.createElement('meta'); metaNode.name = 'viewport'; metaNode.content = 'width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'; metaNode.id = 'metatag'; headID.appendChild(metaNode);} function closeMeta(){ $("#metatag").remove();} $("#add").click(function(){initMeta();alert("meta opened");}); $("#del").click(function(){closeMeta();alert("meta closed");}); }); </script> <input name="add" type="button" value="add metatag" id="add"/> <input name="del" type="button" value="delete metatag" id="del"/> 
+3
android viewport
Aug 30 '10 at 23:08
source share
1 answer

I also note this behavior in Safari iOS.

In fact, you delete the meta tag (checked through the DOM - try notifying $ ("# metatag"). Length after deletion)

The problem is that the viewport itself does not respond to the lack of content in this tag. If you update the content or add a meta tag to the new content, you will see it on the screen. But just by deleting the meta tag, UA seems to think β€œThere is no need to change,” since it does not receive any explicit instructions there.

Hope this helps! Your question / example helped me understand that this is even possible!

+3
Sep 19 2018-11-11T00:
source share



All Articles