Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Tutorials > Javascript

Javascript Javascript Tutorials and Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-2006, 12:43 PM
TcM's Avatar   
TcM TcM is online now
Code Warrior
 
Join Date: Aug 2006
Posts: 9,841
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default JavaScript:Tutorial, Screen Resolution

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:-
Code:
<script language="JavaScript">
function res() 
{
alert('Screen Resolution Is '+screen.width+' by '+screen.height);
}
</script>
And this as the body code

Code:
<body onLoad='res()'
Explanation:-
Can it be simpler than that?

A Preview:-
None

Conclusion:-
As Always Feedback is welcome and the full source is attached!!
Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-03-2006, 01:23 PM
John's Avatar   
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 5,306
Blog Entries: 24
Rep Power: 20
John is just really niceJohn is just really niceJohn is just really niceJohn is just really niceJohn is just really nice
Send a message via AIM to John Send a message via MSN to John
Default

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
Code:
alert('Screen Resolution Is '+screen.width*.9+' by '+screen.height);
lol?

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>
again dont laugh at me, i know nothing about JS
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-03-2006, 01:56 PM
TcM's Avatar   
TcM TcM is online now
Code Warrior
 
Join Date: Aug 2006
Posts: 9,841
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default

Quote:
Originally Posted by Sidewinder View Post
1) How would you calculate 90% of the screen width? Could you just do it like
Code:
alert('Screen Resolution Is '+screen.width*.9+' by '+screen.height);
Yes thats it
Quote:
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>
Yes you can use it as a variable for example:-
Code:
<body>
<script language="JavaScript">
window.open('about:blank','window name','width=screen.width,height=200');
</script>
</body>
This will open a new window with the width of the screen resolution using screen.width directly and height of 200
Or you can declare screen.width as a variable and then use the variable like this:-
Code:
<body>
<script language="JavaScript">
var abc=screen.width
window.open('about:blank','window name','width=abc,height=200');
</script>
</body>
its pretty the same

Quote:
again dont laugh at me, i know nothing about JS
Well I have nothing to laugh to.. thats why I make tutorials
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-06-2006, 11:49 AM
Jordan's Avatar   
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 18,370
Blog Entries: 90
Rep Power: 20
Jordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of lightJordan is a glorious beacon of light
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan Send a message via Yahoo to Jordan
Default

Nice tutorial! Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-06-2006, 12:17 PM
TcM's Avatar   
TcM TcM is online now
Code Warrior
 
Join Date: Aug 2006
Posts: 9,841
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default

Thanks
Sidewinder did my post help you?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-30-2006, 01:37 AM
Programming God
 
Join Date: Dec 2006
Location: Sri lanka
Posts: 908
Rep Power: 0
xtraze is an unknown quantity at this point
Send a message via MSN to xtraze Send a message via Skype™ to xtraze
Default

Really great tutorial and I am sure I am going to use this, thank you for sharing it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 12-30-2006, 05:45 AM
TcM's Avatar   
TcM TcM is online now
Code Warrior
 
Join Date: Aug 2006
Posts: 9,841
Blog Entries: 6
Rep Power: 82
TcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to allTcM is a name known to all
Default

Quote:
Originally Posted by xtraze View Post
Really great tutorial and I am sure I am going to use this, thank you for sharing it.
Hope you use it Thats why I share code, because someone might need it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen resolution NeedHelp PHP Forum 6 05-14-2007 01:54 PM
capture screen shot from an application during run time engr Visual Basic Programming 1 01-29-2007 03:38 PM
16 " screen techni68 Computer Hardware 5 01-22-2007 10:43 AM
Capture the screen in a TImage MrDiaz Pascal/Delphi 3 12-06-2006 11:57 AM
Change Resolution, Change Size Void C# Programming 1 06-13-2006 02:48 PM


All times are GMT -5. The time now is 03:38 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 56%, 75%

Ads