Introduction:-
This is a simple tutorial.. It will get the screen resolution and if you modify it a little bit you can use it to define how your website will be displayed like for example having to home pages then if the screen resolution is 1024x768 it will display index1.html and if the user has 800x600 it will display index2.html.. but then thats up to you in this tutorial I will keep it the simplest possible.
Solution:-
This goes between <head> tags:-
And this as the body codeCode:<script language="JavaScript"> function res() { alert('Screen Resolution Is '+screen.width+' by '+screen.height); } </script>
Explanation:-Code:<body onLoad='res()'
Can it be simpler than that?
A Preview:-
None
Conclusion:-
As Always Feedback is welcome and the full source is attached!!
nice, i know nothing about JavaScript but i have 2 noobie questions.
1) How would you calculate 90% of the screen width? Could you just do it like
lol?Code:alert('Screen Resolution Is '+screen.width*.9+' by '+screen.height);
2) Also since i guess res() returns two values would it be possable to use screen.width as like a varible? say
again dont laugh at me, i know nothing about JSCode:<table width='screen.width'><tr><td>blah></td></tr></table>![]()
Yes thats it
Yes you can use it as a variable for example:-2) Also since i guess res() returns two values would it be possable to use screen.width as like a varible? say
Code:<table width='screen.width'><tr><td>blah></td></tr></table>
This will open a new window with the width of the screen resolution using screen.width directly and height of 200Code:<body> <script language="JavaScript"> window.open('about:blank','window name','width=screen.width,height=200'); </script> </body>
Or you can declare screen.width as a variable and then use the variable like this:-
its pretty the sameCode:<body> <script language="JavaScript"> var abc=screen.width window.open('about:blank','window name','width=abc,height=200'); </script> </body>
Well I have nothing to laugh to.. thats why I make tutorialsagain dont laugh at me, i know nothing about JS![]()
![]()
Nice tutorial! Thanks!
Thanks![]()
Sidewinder did my post help you?
Really great tutorial and I am sure I am going to use this, thank you for sharing it.
All --
Please help.
This does not seem to work for me.
1. I set my monitor to 800x600.
2. I view in IE8 and get screen.width=800 and screen.height=600.
3. I view in FF3.6 and get screen.width=720 and screen.height=540
How can I fix this?
Please advise.
Thank you.
-- Mark Kamoski
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks