Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    40
    Thanks
    16
    Thanked 0 Times in 0 Posts

    ie6, ie7, ie8 not supporting

    Hi,
    For some reason all other browsers do fine with this bit of code, but not ie6, ie7 nor ie8. Any idea why?

    Sorry, the code is pretty long. I hope you don't mind.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>DST-three-requests-combined-7</title>
    
    <!-- UTC/GMT Details part -->
    <script type="text/javascript">
    	// Edit this part only:
    		var setCityOffset = -3; // Set city offset in hours.
    		// 2011
    		var summerdate111 = '1 September, 2011 14:00:00';	// Set dst start date.
    		var summerdate112 = '10 September, 2011 14:00:00';	// Set dst end date.	
    	// End of 'Edit this part only'.
    </script>
    
    <script type="text/javascript">
    	window.onload = standardUtcGmt();
    
    		/*UK DST bit (server correction ---------------------UK-------------------------------- */
    		/*UK DST bit exists to automatically change between hour/hours according to GMT + offset*/
    			var UKtargetdate111 = '27 March, 2011 01:00:00';		
    			var UKtargetdate112 = '30 October, 2011 02:00:00';		
    		
    			var UKservertimestring='<? print date("F d, Y H:i:s", time())?>';
    			this.UKlocaltime=this.UKserverdate=new Date(UKservertimestring);
    	
    			this.UKtargetdate111=new Date(UKtargetdate111);
    			this.UKtargetdate112=new Date(UKtargetdate112);
    			this.UKtargetdate112= (this.UKtargetdate112 - 1000*60*60); //to use official dst ending hour.
    
    			var UKdaylightsaving = (0);
    			if (this.UKtargetdate111 < this.UKlocaltime && this.UKtargetdate112 > this.UKlocaltime){
    		UKdaylightsaving = -60;}
    		/*end of UK DST bit---------------------------UK---------------------------------*/
    			
    		var londonDstCorrec = UKdaylightsaving;
    		var utcDetailHour = 60;
    		var cityOffset = setCityOffset*utcDetailHour;
    		var offSetMinutes = londonDstCorrec + cityOffset;
    	
    	function standardUtcGmt(container){
    		if (!document.getElementById || !document.getElementById(container)) return
    		this.container=document.getElementById(container)
    		this.standardUtcGmtDetails();
    	}
    	
    	standardUtcGmt.prototype.standardUtcGmtDetails=function(){
    		var standardUtcGmtDetailsPlus = ("");
    		if (setCityOffset >= 0){
    			standardUtcGmtDetailsPlus = ("+");
    		}
    		var standardUtcGmtDetailsDigit = (setCityOffset);
    		if (setCityOffset == 0 || setCityOffset == -1 || setCityOffset == 1){
    			var standardUtcGmtDetailsHour = (" hour");
    		}
    			else{
    			standardUtcGmtDetailsHour = (" hours");
    			}
    		this.container.innerHTML=standardUtcGmtDetailsPlus+standardUtcGmtDetailsDigit+standardUtcGmtDetailsHour;
    	}
    </script>
    
    <script type="text/javascript">
    	window.onload = dstOnOff();
    	
    	function dstOnOff(container){
    		if (!document.getElementById || !document.getElementById(container)) return
    		this.container=document.getElementById(container)
    		this.dstOnOffDetails();
    	}
    	
    	dstOnOff.prototype.dstOnOffDetails=function(){
    		this.summerdate111 = new Date(summerdate111);
    		this.summerdate112 = new Date(summerdate112);	
    		this.summerdate112= this.summerdate112 - 1000*60*60 //Possible to use official dst ending hour.
    	
    		summerTime = 0; // no VAR since used in next script in currentOffsetDetails function.
    		var summerTimeInfo = ("");
    		var servertimestring = '<?php print date("F d Y H:i:s", time()) ?>';
    		this.localtime = this.serverdate = new Date(servertimestring);
    		this.localtime.setTime(this.serverdate.getTime()+offSetMinutes*60*1000) // Location offset from GMT.
    		
    		if (this.localtime > this.summerdate111 && this.localtime < this.summerdate112){
    			(summerTime = 1);
    		}
    		if (summerTime == 1){
    			summerTimeInfo = ("+1 hour");
    		}
    			else {
    				summerTimeInfo = ("Not at the moment.");
    			}
    		this.container.innerHTML=summerTimeInfo;
    	}
    </script>
    
    <script type="text/javascript">
    	window.onload = currentOffset();
    	
    	function currentOffset(container){
    		if (!document.getElementById || !document.getElementById(container)) return
    		this.container=document.getElementById(container)
    		this.currentOffsetDetails();
    	}
    	
    	currentOffset.prototype.currentOffsetDetails=function(){
    		var currentOffsetDetailsDigit = (setCityOffset + summerTime);
    		var currentOffsetDetailsPlus = ("");
    		var currentOffsetDetailsHour = ("");
    		if (currentOffsetDetailsDigit >= 0){
    			currentOffsetDetailsPlus = ("+");
    		}
    		if (currentOffsetDetailsDigit == 0 || currentOffsetDetailsDigit == -1 || currentOffsetDetailsDigit == 1){
    			currentOffsetDetailsHour = (" hour");
    		}
    			else{
    				currentOffsetDetailsHour = (" hours");
    			}
    
    	this.container.innerHTML=currentOffsetDetailsPlus+currentOffsetDetailsDigit+currentOffsetDetailsHour;
    	}
    </script>
    <!-- end of UTC/GMT Details part -->
    </head>
    
    
    
    <body>
    <table style="width: 100%">
    	<tr>
    		<td>Standard UTC/GMT: </td>
    		<td><span id="utcGmt"></span></td>
    	</tr>
    	<tr>
    		<td>Daylight Saving Time: </td>
    		<td><span id="dst"></span></td>
    	</tr>
    	<tr>
    		<td>Current UTC/GMT offset: </td>
    		<td><span id="offset"></span></td>
    	</tr>
    </table>
    
    <!-- For 'UTC/GMT Details' part -->
    	<script type="text/javascript">new standardUtcGmt("utcGmt")</script>
    	<script type="text/javascript">new dstOnOff("dst")</script>
    	<script type="text/javascript">new currentOffset("offset")</script>
    <!-- End of 'UTC/GMT Details' part -->
    </body>
    </html>
    Last edited by VIPStephan; 09-05-2011 at 07:38 PM. Reason: fixed code embedding

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    remove your current onload statements

    and use

    Code:
    	window.onload = function(){
    	 standardUtcGmt();
    	 dstOnOff();
         currentOffset();
     }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •