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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with scripts on IE8

    Hi guys,

    I am having some trouble with a system I am using.

    A certain page seems to be crashing IE8. All other browsers are fine. I have tested everything else and seems to come down to the javascript files.

    Can anyone let me know firstly if there is a way to solve any .js issues with IE and secondly would anyone be able to advise of any errors if I posted the .js files?

    It's strange that the problem only occurs in IE8 which makes me think there can't be anything incredibily wrong with the code.

    Any help help would be much appreciated.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Use the error console, then post the relevant code together with whatever error messages you get.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, if I leave 2 .js files in there it crashes completely I have taken script.js out and it loads but says scripts are running slow on this page with a dialogue box.

    It also keeps point to an error here with a cookie script I put in is anything wrong with this?

    Code:
    <!-- START COOKIE CONTROL SCRIPT-->
    <script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
    <script src="http://www.*********.co.uk/cookie_control/grc/cookie-warning.js" type="text/javascript"></script>
    <script type="text/javascript">//<![CDATA[
      cookieControl({
          introText:'<p>This website uses cookies to give you the best online experience.</p>',
          fullText:'<p>Some cookies on this site are essential, and the site won\'t work as expected without them. These cookies are set when you submit a form, login or interact with the site by doing something that goes beyond clicking on simple links.</p><p>We also use some non-essential cookies to anonymously track visitors or enhance your experience of the site. If you\'re not happy with this, we won\'t set these cookies but some nice features of the site may be unavailable.</p><p>By using our site you accept the terms of our <a href="http://www.*****.com/privacy-policy">Privacy Policy</a>.</p>',
          position:'left',
          shape:'triangle', 
          theme:'light', 
          startOpen:true,
          autoHide:5000,
          subdomains:true,
          onAccept:function(cc){cc.setCookie('civicShowCookieIcon', 'no');$('#ccc-icon').hide()},
          onReady:function(){},
          onCookiesAllowed:function(){ccAddAnalytics()},
          onCookiesNotAllowed:function(){},
          countries:['Austria', 'Belgium', 'Bulgaria', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden', 'United Kingdom']
          });
    
             //]]>
    </script>
    Specifically on this line i think:

    Code:
    onCookiesAllowed:function(){ccAddAnalytics()},
    Also got a lot of errors here when I run this script.js through a code checker. I didn't write this though, and not 100% on code so can not diagnose myself

    Code:
    /* 
     *	Functions
     */
    
    	function loadScript(url, callback)
    	{
    		// adding the script tag to the head as suggested before
    	   var head= document.getElementsByTagName('body')[0];
    	   var script= document.createElement('script');
    	   script.type= 'text/javascript';
    	   script.src= url;
    	
    	   // then bind the event to the callback function 
    	   // there are several events for cross browser compatibility
    	   script.onreadystatechange = callback;
    	   script.onload = callback
    	
    	   // fire the loading
    	   head.appendChild(script);
    	}
    	
    	function randomFromTo(from, to){
           return Math.floor(Math.random() * (to - from + 1) + from);
        }
    	
    	/*
    	jQuery Waypoints - v1.1.4
    	*/
    	(function($,k,m,i,d){var e=$(i),g="waypoint.reached",b=function(o,n){o.element.trigger(g,n);if(o.options.triggerOnce){o.element[k]("destroy")}},h=function(p,o){var n=o.waypoints.length-1;while(n>=0&&o.waypoints[n].element[0]!==p[0]){n-=1}return n},f=[],l=function(n){$.extend(this,{element:$(n),oldScroll:0,waypoints:[],didScroll:false,didResize:false,doScroll:$.proxy(function(){var q=this.element.scrollTop(),p=q>this.oldScroll,s=this,r=$.grep(this.waypoints,function(u,t){return p?(u.offset>s.oldScroll&&u.offset<=q):(u.offset<=s.oldScroll&&u.offset>q)}),o=r.length;if(!this.oldScroll||!q){$[m]("refresh")}this.oldScroll=q;if(!o){return}if(!p){r.reverse()}$.each(r,function(u,t){if(t.options.continuous||u===o-1){b(t,[p?"down":"up"])}})},this)});$(n).scroll($.proxy(function(){if(!this.didScroll){this.didScroll=true;i.setTimeout($.proxy(function(){this.doScroll();this.didScroll=false},this),$[m].settings.scrollThrottle)}},this)).resize($.proxy(function(){if(!this.didResize){this.didResize=true;i.setTimeout($.proxy(function(){$[m]("refresh");this.didResize=false},this),$[m].settings.resizeThrottle)}},this));e.load($.proxy(function(){this.doScroll()},this))},j=function(n){var o=null;$.each(f,function(p,q){if(q.element[0]===n){o=q;return false}});return o},c={init:function(o,n){this.each(function(){var u=$.fn[k].defaults.context,q,t=$(this);if(n&&n.context){u=n.context}if(!$.isWindow(u)){u=t.closest(u)[0]}q=j(u);if(!q){q=new l(u);f.push(q)}var p=h(t,q),s=p<0?$.fn[k].defaults:q.waypoints[p].options,r=$.extend({},s,n);r.offset=r.offset==="bottom-in-view"?function(){var v=$.isWindow(u)?$[m]("viewportHeight"):$(u).height();return v-$(this).outerHeight()}:r.offset;if(p<0){q.waypoints.push({element:t,offset:null,options:r})}else{q.waypoints[p].options=r}if(o){t.bind(g,o)}if(n&&n.handler){t.bind(g,n.handler)}});$[m]("refresh");return this},remove:function(){return this.each(function(o,p){var n=$(p);$.each(f,function(r,s){var q=h(n,s);if(q>=0){s.waypoints.splice(q,1)}})})},destroy:function(){return this.unbind(g)[k]("remove")}},a={refresh:function(){$.each(f,function(r,s){var q=$.isWindow(s.element[0]),n=q?0:s.element.offset().top,p=q?$[m]("viewportHeight"):s.element.height(),o=q?0:s.element.scrollTop();$.each(s.waypoints,function(u,x){if(!x){return}var t=x.options.offset,w=x.offset;if(typeof x.options.offset==="function"){t=x.options.offset.apply(x.element)}else{if(typeof x.options.offset==="string"){var v=parseFloat(x.options.offset);t=x.options.offset.indexOf("%")?Math.ceil(p*(v/100)):v}}x.offset=x.element.offset().top-n+o-t;if(x.options.onlyOnScroll){return}if(w!==null&&s.oldScroll>w&&s.oldScroll<=x.offset){b(x,["up"])}else{if(w!==null&&s.oldScroll<w&&s.oldScroll>=x.offset){b(x,["down"])}else{if(!w&&o>x.offset){b(x,["down"])}}}});s.waypoints.sort(function(u,t){return u.offset-t.offset})})},viewportHeight:function(){return(i.innerHeight?i.innerHeight:e.height())},aggregate:function(){var n=$();$.each(f,function(o,p){$.each(p.waypoints,function(q,r){n=n.add(r.element)})});return n}};$.fn[k]=function(n){if(c[n]){return c[n].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof n==="function"||!n){return c.init.apply(this,arguments)}else{if(typeof n==="object"){return c.init.apply(this,[null,n])}else{$.error("Method "+n+" does not exist on jQuery "+k)}}}};$.fn[k].defaults={continuous:true,offset:0,triggerOnce:false,context:i};$[m]=function(n){if(a[n]){return a[n].apply(this)}else{return a.aggregate()}};$[m].settings={resizeThrottle:200,scrollThrottle:100};e.load(function(){$[m]("refresh")})})(jQuery,"waypoint","waypoints",this);
    	
    	;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
    	
    	function recordPromoClick(link, category, action) {
    		_gat._getTrackerByName()._trackEvent(category, action);
    		setTimeout('document.location = "' + link.href + '"', 100);
    	}
    
    /* 
     *	END Functions
     */
    
    
    
    
    /* 
     *	Document ready
     */
    
    	$(document).ready(function() {
    		
    		(function(d, s, id) {
      			var js, fjs = d.getElementsByTagName(s)[0];
    			if (d.getElementById(id)) {return;}
      			js = d.createElement(s); js.id = id;
      			js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
      			fjs.parentNode.insertBefore(js, fjs);
    		}(document, 'script', 'facebook-jssdk'));
    		
    		loadScript('//platform.twitter.com/widgets.js', '');
    		loadScript('https://apis.google.com/js/plusone.js', '');
    		
    		$('.change_img').click(function() {
    			
    			var rand = randomFromTo(1,46);
    			var img = 'http:/********.co.uk/grc/libs/img/photos/'+rand+'.jpg';
    			$('.inspire_img').attr('src',img);
    			
    		});
    		
    		$.waypoints.settings.scrollThrottle = 30;
    		$('.chat').waypoint(function(event, direction) {
    			if (direction === 'down') {
    			  $('.btt').fadeIn(500);
    			}
    			else {
    			  $('.btt').fadeOut(500);
    			}
    		});
    		
    		$('.btt').bind('click',function() {
    			$.scrollTo('.advert', 500, {easing:'linear'} );
    		});
    		
    		
    		////////////////////////////////////////////////////////////////
    		////	MAILING LIST SIGN UP POPUP - USES HTML5 LOCALSTORAGE. DOES NOT OPERATE IN IE7
    		////////////////////////////////////////////////////////////////
    		/*if (typeof(localStorage) == "undefined" ) {
    			// Localstorage not supported. Do nothing
    		} else {
    			try {
    				
    				if(document.URL.indexOf("/cruise") >= 0 || document.URL.indexOf("/search") >= 0 || document.URL.indexOf("/promo") >= 0){ 
    					var page_ok = 0;
    				} else {
    					var page_ok = 1;
    				}
    				
    				// If localstorage items not set then set them!
    				if(localStorage.getItem("returning_visitor") === null) {
    					localStorage.setItem("returning_visitor", "1");
    				}
    				if(localStorage.getItem("mailing_list_status") === null) {
    					localStorage.setItem("mailing_list_status", "0");
    				}
    				if(localStorage.getItem("page_views") === null) {
    					localStorage.setItem("page_views", "0");
    				}
    				
    				// Check if user has already signed up
    				var mailing_list_status = localStorage.getItem("mailing_list_status");
    				
    				// Update page views count
    				var cur_views = localStorage.getItem("page_views");
    				var new_views = parseInt(cur_views) + 1;
    				localStorage.setItem("page_views", new_views);
    				
    				if (parseInt(new_views) >= 3 && parseInt(mailing_list_status) == 0 && page_ok == 1) {
    					$('.white-bg').removeClass('hidden');
    					$('.mailing_list_popup').fadeIn(1000);
    					localStorage.setItem("mailing_list_status", "1");
    				}
    					
    				
    			} catch (e) {
    				if (e) {
    					alert(e);
    				}
    			}
    		}*/
    		
    		$('.white-bg').livequery('click',function() {
    			
    			if($('.white-bg').hasClass('hidden')) {
    				$('.white-bg').removeClass('hidden');
    			} else {
    				$('.white-bg').addClass('hidden');
    			}
    			
    		});
    		
    		$('.close_perm').livequery('click',function() {
    			
    			$('.mailing_list_popup').fadeOut(600);
    			
    			if($('.white-bg').hasClass('hidden')) {
    				$('.white-bg').removeClass('hidden');
    			} else {
    				$('.white-bg').addClass('hidden');
    			}
    
    		});
    		
    		$('#join_mailing_top_btn').livequery('click',function() {
    			
    			$('.white-bg').removeClass('hidden');
    			$('.mailing_list_popup').fadeIn(1000);
    
    		});
    		
    		$('#join_mailing_list_home_email').livequery('click',function() {
    			var email_val = $(this).val();
    			if(email_val == 'Enter your email address') {
    				$(this).val('');
    			}
    		});
    		
    		$('#join_mailing_list_home_email').livequery('focusout',function() {
    			var email_val = $(this).val();
    			if(email_val == '') {
    				$(this).val('Enter your email address');
    			}
    		});
    		
    		$('#join_mailing_list_top_email').livequery('click',function() {
    			var email_val = $(this).val();
    			if(email_val == 'Enter your email address') {
    				$(this).val('');
    			}
    		});
    		
    		$('#join_mailing_list_top_email').livequery('focusout',function() {
    			var email_val = $(this).val();
    			if(email_val == '') {
    				$(this).val('Enter your email address');
    			}
    		});
    		
    		// Destinations page gallery
    		$('.rivers_list .gallery img').live('click',function() {
    			
    			$('.white-bg').removeClass('hidden');
    			$('.fullsize_img').removeClass('hidden');
    			
    			var img_url = $(this).attr('id');
    			
    			$('.fullsize_img .img').html('<img src="' + img_url + '" />');
    			
    			var img_width = $('.fullsize_img .img img').width();
    			var img_height = $('.fullsize_img .img img').height();
    			
    			$('.fullsize_img .img img').attr('width',img_width);
    			$('.fullsize_img .img img').attr('height',img_height);
    			
    			$('.fullsize_img').css('width',img_width);
    			$('.fullsize_img').css('height',img_height);
    			$('.fullsize_img').css({ zIndex: '1001' });
    			
    			$('.fullsize_img').css('top','50%');
    			$('.fullsize_img').css('left','50%');
    			
    			$('.fullsize_img').css('marginTop',-img_height/2);
    			$('.fullsize_img').css('marginLeft',-img_width/2);
    			
    		});
    		
    		$('.fullsize_img .close').live('click',function() {
    				
    			$('.fullsize_img').addClass('hidden');
    			$('.white-bg').addClass('hidden');
    												 
    		});
    		
    		$('.white-bg').livequery('click',function() {
    
    			$('.fullsize_img').addClass('hidden');
    			$('.white-bg').addClass('hidden');
    			
    		});
    		
    	});
    
    /* 
     *	END Document ready
     */
    Last edited by paulm; 05-31-2012 at 04:08 PM.

  • #4
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any help on this?


  •  

    Posting Permissions

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