Similar Question:
Javascript code to run after page has loaded
In my ASP.NET 4.0 application, I am using JavaScript to show the client's time zone offset in a text box:- `
<script type="text/javascript">
function GetTimeZoneOffset() {
var d = new Date()
var gmtOffSet = -d.getTimezoneOffset();
var gmtHours = Math.floor(gmtOffSet / 60);
var GMTMin = Math.abs(gmtOffSet % 60);
var dot = ".";
var retVal = "" + gmtHours + dot + GMTMin;
document.getElementById('<%= offSet.ClientID%>').value = retVal;
}
</script>
`
HTML Markup
<asp:HiddenField ID="clientDateTime" runat="server" />
<asp:HiddenField ID="offSet" runat="server" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></body>
How do I trigger this function on page load to display the offset value in the textbox?