我試圖在內容頁面(引用母版頁)中使用JavaScript方法來獲取當前屏幕尺寸,並將其寫入標籤。在內容頁面中使用JavaScript獲取頁面尺寸
到目前爲止,我沒有運氣。我試圖在主頁和內容頁面中執行此操作,但該方法根本無法工作。
有人可以提供解決方案嗎?
母版:
<head runat="server">
<title>Lake, Smit People</title>
<!--[if IE ]>
<link rel="stylesheet" type="text/css" href="ProfileStypeSheetIE.css" />
<![endif]-->
<!--[if !IE]>-->
<link href="ProfileStypeSheet.css" rel="stylesheet" type="text/css" />
<!--<![endif]-->
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1 { width: 378px; }
</style>
</head>
Default.aspx的
<asp:Content ID="Content5" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
var height = screen.height;
document.getElementById('<%= hiddenLabel.ClientID%>').value = height;
</script>
</asp:Content>
你是怎麼做到的?我的意思是你的代碼不工作? – codingbiz 2012-08-06 12:46:21
請顯示您的代碼,並告訴我們您使用的是什麼網頁瀏覽器。 – funerr 2012-08-06 12:47:18
添加了代碼。道歉.. – TheGeekZn 2012-08-06 13:03:55