New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Javascript problems in safari


Post Reply New Thread Subscribe

 
Thread Tools
pandora_dora

 
Member Since: Sep 27, 2011
Posts: 1
pandora_dora is on a distinguished road

pandora_dora is offline
Hello all,

Got a bit of a frustrating conundrum on my hands. I've built a website that uses particletree's dynamic resolution dependent layout in order to recognize the user's screen size and change the stylesheet accordingly.

Now, this script seems to work in every browser (firefox, IE, chrome, opera) except safari, and I can't figure out what I'm doing wrong. I know my javascript is enabled because other scripts on my website work fine in safari. Also, I ran the script debugger and it showed no errors.

The website is : www.sheket.co.il
(excuse the possible jibrish, the website is in hebrew)

And the specific bit of javascript code is:
Code:
window.onload= changeLayout;

	function getBrowserWidth(){
		if (window.innerWidth){
			return window.innerWidth;}	
		else if (document.documentElement && document.documentElement.clientWidth != 0){
			return document.documentElement.clientWidth;	}
		else if (document.body){return document.body.clientWidth;}		
			return 0;
	}



function dynamicLayout(){
	var browserWidth = getBrowserWidth();

	

	if (browserWidth < 900){
		changeLayout('small');
	}
	
	if ((browserWidth >= 900) && (browserWidth <= 1200)){
		changeLayout('medium');
	}
	
}




function changeLayout(description){
   var i, a;
   for(i=0; (a = document.getElementsByTagName('link')[i]); i++){
	   if(a.getAttribute('title') == description){a.disabled = false;}
	   else if(a.getAttribute("title") != 'default'){a.disabled = true;}
   }
}



function addEvent( obj, type, fn ){ 
	   if (obj.addEventListener){ 
	      obj.addEventListener( type, fn, false );
	   }
	   else if (obj.attachEvent){ 
	      obj['e'+type+fn] = fn; 
	      obj[type+fn] = function(){ obj['e'+type+fn]( window.event ); } 
	      obj.attachEvent( 'on'+type, obj[type+fn] ); 
	   } 
	}
 
	
	
addEvent(window, 'load', dynamicLayout);
	addEvent(window, 'resize', dynamicLayout);
Anyone have any ideas? Thanks!
QUOTE Thanks
Cdoimne

 
Member Since: Aug 21, 2011
Posts: 36
Cdoimne is on a distinguished road
Mac Specs: Late 2010 MacBook Pro 13 Inch

Cdoimne is offline
I'm not a huge javascript coder so sorry if this doesn't help you but when I want the size of the content to be proportional to the size of the browser window I simply use a css
Code:
width: 90%;
or something just so that it resizes according to browser window size. Sorry if that wasn't your intention but your webpage seems to do what you want it to just fine (at least on my computer). What kind of mac do you have and also be sure to have the latest update of Safari!
QUOTE Thanks

Post Reply New Thread Subscribe


« Where can i get iWeb??? | auto play slide show in Iweb »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Problems w/ Safari kmurray1231 OS X - Operating System 15 10-03-2010 06:34 PM
Hotmail problems on Safari... pod OS X - Apps and Games 0 10-16-2007 04:16 PM
Javascript and Safari (earlier versions) noodles Web Design and Hosting 0 02-17-2005 03:46 PM
Javascript and Frames problem in Safari HarrySpier Web Design and Hosting 3 11-09-2004 05:47 PM
Safari Javascript problem babszem Web Design and Hosting 0 02-26-2004 04:21 PM

All times are GMT -4. The time now is 11:24 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?