Results 1 to 2 of 2
  1. #1

    Member Since
    Sep 27, 2011
    Javascript problems in safari
    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 :
    (excuse the possible jibrish, the website is in hebrew)

    And the specific bit of javascript code is:
    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){
    	if ((browserWidth >= 900) && (browserWidth <= 1200)){
    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!

  2. #2

    Member Since
    Aug 21, 2011
    Late 2010 MacBook Pro 13 Inch
    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
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Safari Javascript Help
    By bluecollar01 in forum Web Design and Hosting
    Replies: 0
    Last Post: 04-12-2011, 10:13 AM
  2. Java / Javascript Problems in Firefox, Safari, Opera
    By Tubamusic in forum OS X - Operating System
    Replies: 4
    Last Post: 09-25-2010, 07:56 PM
  3. Safari and javascript problem.
    By DaveDawn in forum Web Design and Hosting
    Replies: 3
    Last Post: 06-28-2008, 01:55 PM
  4. How do I debug javascript in Safari?
    By Srikanth.S in forum Web Design and Hosting
    Replies: 3
    Last Post: 08-05-2005, 12:40 PM
  5. Safari Javascript problem
    By babszem in forum Web Design and Hosting
    Replies: 0
    Last Post: 02-26-2004, 04:21 PM

Posting Permissions

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