asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Code Samples
Components
Tools
New
Free
Downloads
Vendors
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

View BrowserAPI Demo

/**************************************************************************\ 
 * Name:	BrowserAPI()
 * Author:	Greg Miley
 * Date:	03April02
 * Description:	
 *		Provide clean access to browser objects.
 *		Right now you must provide a StringID for the element you wish
 *		to access. This API wrapper provides access to DOM as well as
 *		older version 4s of IE and NN. Read the internal documentation
 *		comments for further explanation of each method/property.
 * Usage:
 *		1) Create a new instance of the object.
 *			var Browser = new BrowserAPI();
 *		2) Access objects via Browser.ObjRef('ObjIDString')
 *			Browser.ObjRef('mySpan').id = "mySpan";
 *			2.1) Move Items to specified postions.
 *				Browser.ObjRef('mySpan').MoveTo(nX,nY);
 *			2.2) Show and Hide items in document.
 *				Browser.ObjRef('mySpan').Show();
 *				Browser.ObjRef('mySpan').Hide();
 *			2.3) Resize Items to specified size.
 *				Browser.ObjRef('mySpan').Resize(nX,nY);
 *		3) Access styles via Browser.StyleRef('ObjIDString')
 *			Browser.StyleRef('mySpan').border = "1px #000000 solid";
 * Notes:
 *		More to come on this development. I will be adding more 
 *		methods as I complete them. Comments or suggestions to 
 *		greg_s_miley@hotmail.com
 *
 *		As a rule you MUST have styles set for a lot of stuff
 *		to be accessed correctly. This is true whether you use
 *		this API or not. This API does NOT set up initial style
 *		for you. You have to do that yourself.
 *
 * Modification History:
 *	Name		When		Why
 **========================================================
 *	g miley		04.05.02	Added .Show() .Hide() and .MoveTo(X,Y)
 *	g miley		04.05.02	Added .Resize()
 *
\**************************************************************************/

function BrowserAPI() {
	var Root = this;
	this.BrowserID = function BrowserID() {
	// This funtion acts as a dynamic property of the API.
	// It returns the browser capabilities. (DOM | IE | NN)
	// Returns blank if nothing is supported.
		if(parseInt(navigator.appVersion) >= 4) {
			if(document.getElementById) {
				return "DOM";
			} else if(document.layers) {
				return "NN";
			} else {
				return "IE";
			}
		}
		return "";
	}
	this.ObjRef = function GetObject(loObject) {
	// Reflows object path to access object by a string
	// object id.
		var ObjID = loObject;
		var myObj;
		var lcAllAccess = "";
		var BrowType = Root.BrowserID();
		if(BrowType == "IE") {
			lcAllAccess = "all.";
		}
		if(typeof loObject == "string") {
			if( BrowType == "DOM") {
				myObj = eval(document.getElementById(loObject));
			} else {
				myObj = eval("document." + lcAllAccess + loObject);
			}
		} else {
			myObj = loObject;
		}
		// Move item method
		myObj.MoveTo = function MoveTo(Xpos, Ypos) {
			var movObj = Root.StyleRef(ObjID);
			movObj.top = Ypos;
			movObj.left = Xpos;
		}
		// Show Item method
		myObj.Show = function Show() {
			var showObj = Root.StyleRef(ObjID);
			showObj.visibility = "visible";
		}
		// Hide item method
		myObj.Hide = function Hide() {
			var showObj = Root.StyleRef(ObjID);
			showObj.visibility = "hidden";
		}
		// Resize item method
		myObj.Resize = function Resize(Xsize, Ysize) {
			var sizeObj = Root.StyleRef(ObjID);
			sizeObj.height = Ysize;
			sizeObj.width = Xsize;
		}
		return myObj
	}
	this.StyleRef = function GetStyleObject(loStyleObject) {
	// Accesses the style attributes of an element using .ObjRef()
		var myObj;
		var lcStyleAccess = "";
		myObj = Root.ObjRef(loStyleObject);
		if(Root.BrowserID() !== "NN") {
			myObj = myObj.style;
		}
		return myObj;
	}
}

// initialize the API object.
var Browser = new BrowserAPI();






email this code sample to a colleague


Support the Active Server Industry



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers