这是我发布的问题并得到了答案。
https://stackoverflow.com/questions/17780797/set-contents-of-page-according-to-browser-resolution
在Firefox和Chrome中,每件事情都运行良好。但是需要的是它必须在IE中工作。但它始终在Captcha下提供QR码。这是我改变了我的代码。
<div style="border: 1px solid lightgrey; border-radius: 10px 10px 10px 10px; width: 825px">
<ul id="holder" style="display:inline-block; list-style-type: none;">
<li style="display:inline-block; list-style-type: none">
<div class="captcha" >
@Html.Captcha("Refresh", "Enter Captcha", 5, "Is required field.", true)<div style="color: Red;">@TempData["ErrorMessage"]</div>
</div>
</li>
<li style="display:inline-block; list-style-type: none;">
<div id="qrcode" class="qrcode">
<img src="@Url.Action("QrCode", "Qr", new { url = Model.ShortUrl })" onclick="AppendURL('@this.Model.ShortUrl')"/>
</div>
</li>
</ul>
</div>
JS代码是:
window.onresize = getWindowWidthHeight;
window.onload = getWindowWidthHeight;
function getWindowWidthHeight(event) {
var width = window.innerWidth;
var height = window.innerHeight;
// alert(width);
//alert( $(window).width());
var firstLi = document.getElementById('holder').children[0];
if (width > 600) {
firstLi.style.display = 'inline-block';
} else {
firstLi.style.display = 'list-item';
}
};
请帮助。谢谢。