Metachecker.net
|
TrafficChecker.net
|
RankChecker.net
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advanced Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
DHTML Script - PageObject
[View Sample]
To understand what this script does you might wanna check out the documentsize tutorial in the tutorials section.
Insert into <HEAD>
<script type="text/javascript" language="JavaScript"> /******************************************************************************** Copyright (C) 1999 Thomas Brattli This script is made by and copyrighted to Thomas Brattli at www.bratta.com Visit for more great scripts. This may be used freely as long as this msg is intact! I will also appriciate any links you could give me. ********************************************************************************/ //Default browsercheck, added to all scripts! function checkBrowser(){ this.ver=navigator.appVersion this.dom=document.getElementById?1:0 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; this.ie4=(document.all && !this.dom)?1:0; this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; this.ns4=(document.layers && !this.dom)?1:0; this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) return this } bw=new checkBrowser() /******************************************************************************** Here's the pageobject, see www.bratta.com/dhtml for tutorial on how it works. ********************************************************************************/ function makePageObject(){ this.x=0; this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth-20; this.y=0; this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight-4; this.x50=this.x2/2; this.y50=this.y2/2; this.x10=(this.x2*10)/100 this.y10=(this.y2*10)/100 this.x15=(this.x2*15)/100 this.y15=(this.y2*15)/100 return this; } /******************************************************************************** Making the objects, Cross-browser and makes a moveIt function that will move the object easely ********************************************************************************/ function makeObj(obj,nest){ nest=(!nest) ? '':'document.'+nest+'.' this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0; this.moveIt=b_moveIt; return this } function b_moveIt(x,y){ this.css.left=x this.css.top=y } /******************************************************************************** Here we call the object constructor to make objects, then we move them to a choosen place on the page. ********************************************************************************/ function pageInit(){ //first me make a page object page=new makePageObject() //then we make the layer objects oCenter=new makeObj('divCenter') oRightTop=new makeObj('divRightTop') oRightBottom=new makeObj('divRightBottom') oLeftTop=new makeObj('divLeftTop') oLeftBottom=new makeObj('divLeftBottom') //now we place them //The divs has a width and height of 100, so we divide that with 2 to place it at center oCenter.moveIt(page.x50-50,page.y50-50) oRightTop.moveIt(page.x2-100,page.y) oRightBottom.moveIt(page.x2-100,page.y2-100) oLeftTop.moveIt(page.x,page.y) oLeftBottom.moveIt(page.x,page.y2-100) //Takes care of the resizing. window.onresize=resized; } function resized(){ page2=new makePageObject() if(page2.x2!=page.x2 || page2.y2!=page.y2){ location.reload() //If the width or height have changed we reload the page. } } //Calls the init function on pageload; onload=pageInit; </script>
Insert into <BODY>
<div id="divCenter" style="position:absolute; font-family:arial; font-size:10pt; padding:5pt; width:100; height: 100; clip:rect(0,100,100,0); background-color:#CCCCCC; layer-background-color:#CCCCCC">This is on the center and middle of the page</div> <div id="divRightTop" style="position:absolute; font-family:arial; font-size:10pt; padding:5pt; width:100; height: 100; clip:rect(0,100,100,0); background-color:#CCCCCC; layer-background-color:#CCCCCC">This is on the top-right</div> <div id="divRightBottom" style="position:absolute; font-family:arial; font-size:10pt; padding:5pt; width:100; height: 100; clip:rect(0,100,100,0); background-color:#CCCCCC; layer-background-color:#CCCCCC">This is on the bottom-right</div> <div id="divLeftTop" style="position:absolute; font-family:arial; font-size:10pt; padding:5pt; width:100; height: 100; clip:rect(0,100,100,0); background-color:#CCCCCC; layer-background-color:#CCCCCC">This is on the top-left</div> <div id="divLeftBottom" style="position:absolute; font-family:arial; font-size:10pt; padding:5pt; width:100; height: 100; clip:rect(0,100,100,0); background-color:#CCCCCC; layer-background-color:#CCCCCC">This is on the bottom-left</div>
Other Options