| Web Design and Hosting Creating sites, scripting, and hosting discussions. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Sep 27, 2011
Posts: 1
![]() |
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);
|
| QUOTE Thanks | |
![]() Member Since: Aug 21, 2011
Posts: 34
![]() Mac Specs: 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
Code:
width: 90%; |
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Problems w/ Safari | kmurray1231 | OS X - Operating System | 15 | 10-03-2010 05:34 PM |
| Hotmail problems on Safari... | pod | OS X - Apps and Games | 0 | 10-16-2007 03:16 PM |
| Javascript and Safari (earlier versions) | noodles | Web Design and Hosting | 0 | 02-17-2005 02:46 PM |
| Javascript and Frames problem in Safari | HarrySpier | Web Design and Hosting | 3 | 11-09-2004 04:47 PM |
| Safari Javascript problem | babszem | Web Design and Hosting | 0 | 02-26-2004 03:21 PM |
All times are GMT -4. The time now is 02:24 AM.
Powered by vBulletin