All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
Client,Side,JavaScript,communicating,with,Ser
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,252. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Web Online Examination
By Suhas Manjunath Kashyap on 11/7


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

A Screen Size Redirection With Variable Passed Back To Server

Print
Email
 
VB icon
Submitted on: 11/29/2001 1:30:43 AM
By: Brian Reeves 
Level: Intermediate
User Rating: By 1 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 16847 times.
 
(About the author)
 
     Client Side JavaScript communicating with Server in order to pass the ScreenSize and BrowserType to the server.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: A Screen Size Redirection With V
    '     ariable Passed Back To Server
    ' Description:Client Side JavaScript com
    '     municating with Server in order to pass 
    '     the ScreenSize and BrowserType to the se
    '     rver.
    ' By: Brian Reeves
    '
    ' Inputs:You can specify the "URL", "Pag
    '     eName", "Description", "Keywords", and "
    '     Title" (Which I populate from a SQL data
    '     base)
    '
    ' Returns:Use this to get the results
    bParam = Request.QueryString("b")
    strBrowser = Left(bParam, 2)
    strBrowserVer = Left(bParam, 3)
    strVersion = Mid(bParam, 3, 1)
    strResolution = Right(bParam, 1)
    '
    ' Assumes:This is cut and paste code (wi
    '     th a lot taken out) if you need me to up
    '     date it with another version let me know
    '     
    '
    ' Side Effects:Uses JavaScript and runs 
    '     on a good deal of browsers.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=7021&lngWId=4    'for details.    '**************************************
    
    <%
    'This code was written by Brian Reeves (
    '     ketapillar 'at' hotmail 'dot' com)
    'If you want to use this code go ahead j
    '     ust make some note in the comments
    'referencing that i coded it.
    Dim strURL, strDocument, strDescription, strKeywords, strTitle
    ' Below is for setting the variables in 
    '     real life I use a database
    'to populate these fields.
    strURL = "http://www.url.com/" 'remember the slash
    ' could leave bland if you are in the sa
    '     me directory example below
    ' strURL = ""
    strDocument = "pagename.asp"'name of the page
    strDescription = "This is the page description"
    strKeywords = "this, is, a, listing, of, the, keywords, for, this, page"
    strTitle = "This Pages Title"
    ' 
    %>
    <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META name="Description" content="<%= strDescription%>">
    <META name="Keywords" content="<%= strKeywords %>">
    <TITLE><%= strTitle %></TITLE>
    </HEAD>
    <BODY title="<%= strBodyTitle %>">
    <SCRIPT language="JavaScript" type="text/javascript">
    	/*******************************************************
    	Resolution Redirection JavaScript. Is supported In ie3+,
    	and ns3+ All of the code was rewritten from examples that
    	i have no idea where they came from.
    	
    	Author: Brian Reeves
    	Email:ketapillar 'at' hotmail 'dot'com
    	********************************************************/
    		breakFrames();
    		
    		var strNewLocation="";					// Used as placeholder
    		var strURL="<%= strURL %>"; 			// URL of redirect document
    		var strDocument="<%= strDocument %>";	// Name of redirect document
    		
    		var strBrowser = getBrowser();
    		var strResolution = getResolution();
    	
    		strNewLocation=strURL + strDocument + "?b=" + strBrowser + strResolution;
    		if((strBrowser == "ie5") || (strBrowser == "ie4") || (strBrowser == "ie3") || (strBrowser == "ns4"))
    			{document.location.href=strNewLocation;}		//	Redirecting
    		Else {document.location.href="oldsite/index.html";}	// Redirecting To oldsite
    	/********************************************************
    	variable getResolution();
    	Gets the clients available screen width and returns the 
    	width In "a,b,c,d or e" depending on the resolution. 
    	Will return "z" On unsupported resolutions.
    	Possible future modifications could be if both are null,
    	open a new browser window "full screen" write an image
    	100% x 100% Get the image size and return the values.
    	********************************************************/
    	function getResolution(){
    		var iWidth, iHeight, sRes;
    		if (window.innerWidth != null) {
    			iWidth = window.innerWidth;
    			iHeight = window.innerHeight; 
    		}
    		Else if (document.body.clientWidth != null) {
    			iWidth = document.body.clientWidth;
    			iHeight=document.body.clientHeight;
    		}
    		Else { iWidth = 640; }
    		if(iWidth <= 640) 
    			{sRes = "a";}		// 640 x 480 Resolution
    		Else if(iWidth <= 800)
    			{sRes = "b";}		// 800 x 600 Resolution
    		Else if(iWidth <= 1024)
    			{sRes = "c";}		// 1024 x 800 Resolution
    		Else if(iWidth <= 1280)
    			{sRes = "d";}		// 1280 x 1024 Resolution
    		Else if(iWidth <= 1600)
    			{sRes = "e";}		// 1600 x 1200 Resolution
    		Else {sRes = "z"}
    		return (sRes);
    	}
    	/********************************************************
    	getBrowser();
    	Gets the users browser Type and returns "ie5, ie4, ie3, 
    	ns6, ns4, ns3". Will return "other" On any other browser.
    	********************************************************/
    	function getBrowser() {
    		var vBrowser=navigator.appName;			
    		var vVersion=navigator.appVersion;
    		var sBrowser;
    		if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("6")>=0)
    			{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
    		Else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("5")>=0)
    			{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
    		Else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("4")>=0)
    			{sBrowser="ie4";}		// Microsoft Internet Explorer 4.x
    		Else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("3")>=0)
    			{sBrowser="ie3";}	// Microsoft Internet Explorer 3.x
    		Else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("6")>=0)
    			{sBrowser="ns6";}	// Netscape Navigator 6.x
    		Else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("4")>=0)
    			{sBrowser="ns4";}	// Netscape Navigator 4.x
    		Else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("3")>=0)
    			{sBrowser="ns3";}	// Netscape Navigator 3.x
    		Else
    			{sBrowser="other";}	// All Others 	
    		return(sBrowser);
    	}	
    	/********************************************************
    	breakFrames();
    	breakFrames() Tests if user was linked To here within
    	a frame. if True Then will reopen current location
    	In the parent window.
    	********************************************************/
    	function breakFrames(){
    		if(self.parent.frames.length != 0)
    			{self.parent.location = document.location;}
    	}
    	
    </SCRIPT>
    <!-- Page To show to search engines and browsers that Do Not support javascript -->
    </BODY>
    </HTML>


Other 5 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
5/21/2002 6:45:16 AMmad_rappa

This isn't ASP... it's Javascript....
(If this comment was disrespectful, please report it.)

 
5/21/2002 6:46:25 AMmad_rappa

ok... sorry... didn't read it all.... :)
(If this comment was disrespectful, please report it.)

 
3/14/2003 3:56:40 AM

uiyewjkgs
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.