By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,178 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,178 IT Pros & Developers. It's quick & easy.

Finding browser screen width

P: n/a
What is best way to find browser screen width using javascript that is
compatible with all types of browsers.
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
In article <76**************************@posting.google.com >,
ma*********@hotmail.com enlightened us with...
What is best way to find browser screen width using javascript that is
compatible with all types of browsers.


There is no one way that works with all browsers. You have to putz around
with the different methods. It's in the archives here - this question gets
posed rather frequently. Check google groups.

Why would you need it, anyway?
Good coding would have content fit readably no matter the width. The only
reason you might want it is to check stats or something. If you're trying to
resize content and whatnot, that's making a mountain out of a molehill. There
are way cleaner ways of getting your stuff to work in all browser windows.

--
--
~kaeli~
No one is listening until you make a mistake.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

P: n/a
kaeli wrote:
What is best way to find browser screen width
Why would you need it, anyway?
Good coding would have content fit readably no matter the width.


Well, I'm planning some photo gallery software which will use the window
size to select a default image size (which the user can override if they so
wish). So there are some reasonable uses for it :)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #3

P: n/a
In article <cm*******************@news.demon.co.uk>, do*****@yahoo.com
enlightened us with...
kaeli wrote:
What is best way to find browser screen width

Why would you need it, anyway?
Good coding would have content fit readably no matter the width.


Well, I'm planning some photo gallery software which will use the window
size to select a default image size (which the user can override if they so
wish). So there are some reasonable uses for it :)


Well, then, post your screen size detecting code for the OP. ;)

--
--
~kaeli~
Never say, "Oops!"; always say, "Ah, interesting!"
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

P: n/a

"mgandra" <ma*********@hotmail.com> escreveu na mensagem
news:76**************************@posting.google.c om...
What is best way to find browser screen width using javascript that is
compatible with all types of browsers.


Javascript as a property that tell us the user screen resolution (not the
browser´s) If is that, you wish to acomplish just do as follow:
1 - create an input the HTML body
<body>
<input size="50" name="watheveryouwish">
<input type="button" value="Resolution" onclick="dofunction()">

2- create a script with function to capture screen resolution

<script type="text/javascript">

width=screen.width
height=screen.height

function dofunction()
{
watheveryouwish.value="You´re screen resolution is " +width+"*"+height
}

</script>

Jul 23 '05 #5

P: n/a
mgandra wrote:
What is best way to find browser screen width using javascript that is
compatible with all types of browsers.


The best way is to leave the browser window size the hell alone. It
isn't your browser and it isn't on your PC so stop trying to interfere
with what other people have chosen to do. Instead, use percentage sizes
for the components of your web page so that they fit into whatever space
the user chooses to let you use.
Jul 23 '05 #6

P: n/a
kaeli wrote:
Well, I'm planning
Well, then, post your screen size detecting code for the OP. ;)


I've got to write the indexing and scaling Perl first :)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.