Resizing a Layer (W3C) : Layer « HTML « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » HTML » Layer 
Resizing a Layer (W3C)

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 

John Wiley & Sons CopyRight 2001
*/

<HTML>
<HEAD>
<TITLE>Layer Resizing</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var engaged = false
var offsetX = 0
var offsetY = 0
function resizeIt(evt) {
    evt = (evt? evt : (window.event? window.event : ""
    var targElem = (evt.target? evt.target : evt.srcElement
    if (targElem.className == "draggable") {
        if (engaged) {
            if (evt.pageX) {
                targElem.style.width = (evt.pageX - targElem.offsetLeft - offsetX"px"
                targElem.style.height = (evt.pageY - targElem.offsetTop - offsetY"px"

else {
                var elemWidth = evt.clientX - targElem.offsetLeft - offsetX - 
                    (parseInt(targElem.style.left- parseInt(targElem.offsetLeft))
                var elemHeight = evt.clientY - targElem.offsetTop - offsetY - 
                    (parseInt(targElem.style.top- parseInt(targElem.offsetTop))
                targElem.style.width = elemWidth + "px"
                targElem.style.height = elemHeight + "px"
            }
        }
    }
}
function engage(evt) {
    evt = (evt? evt : (window.event? window.event : ""
    var targElem = (evt.target? evt.target : evt.srcElement
    if (targElem.className == "draggable") {
       while (targElem.id != "myLayer" && targElem.parentNode) {
           targElem = targElem.parentNode
        }
        if (targElem.id == "myLayer") {
            if (evt.pageX && (evt.pageX > ((parseInt(targElem.style.width20
            targElem.offsetLeft)) && (evt.pageY > 
            ((parseInt(targElem.style.height20+ targElem.offsetTop))) {
                offsetX = evt.pageX - parseInt(targElem.style.width- targElem.offsetLeft
                offsetY = evt.pageY - parseInt(targElem.style.height- targElem.offsetTop
                engaged = true
            else if ((evt.offsetX > parseInt(targElem.style.width20&& (evt.offsetY > 
                parseInt(targElem.style.height20)) {
                offsetX = evt.offsetX - parseInt(targElem.style.width- document.body.scrollLeft
                offsetY = evt.offsetY - parseInt(targElem.style.height- document.body.scrollTop
                engaged = true
                if (navigator.userAgent.indexOf("Win"== -1) {
                    offsetX += document.body.scrollLeft
                    offsetY += document.body.scrollTop
                   }
            }
            return false
        }
    }
}
function release(evt) {
    evt = (evt? evt : (window.event? window.event : ""
    var targElem = (evt.target? evt.target : evt.srcElement
    if (targElem.className == "draggable") {
        while (targElem.id != "myLayer" && targElem.parentNode) {
            targElem = targElem.parentNode
        }
        if (engaged && targElem.id == "myLayer") {
            engaged = false
        }
    }
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Resizing a Layer (W3C)</H1>
<HR>
<DIV ID="myLayer" CLASS="draggable" STYLE="position:absolute; top:170; left:100;
 width:300; height:190; background-color:lightblue">
<SPAN>Here is some content inside the layer. See what happens to it as you
 resize the layer via the bottom-right 20-pixel handle.</SPAN>
</DIV>
<SCRIPT LANGUAGE="JavaScript">
document.onmousedown = engage
document.onmouseup = release
document.onmousemove = resizeIt
document.onmouseout = release
</SCRIPT>
</BODY>
</HTML>


           
       
Related examples in the same category
1. Layer 'srcFilter' Example
2. Monitors divisions (or layers) on dynamic Web pages (DHTML)
3. Hide and show layer
4.  Layer Background Colors (W3C)
5. Setting Layer Backgrounds (W3C)
6. The layer while rolling over the link.
7. Accessing Layers with JavaScript
8. 'layer' and 'ilayer' Tag Properties
9. Detecting Navigator and Internet Explorer
10.  Adjusting Layer clip Properties (W3C)
11. Comparison of Layer and Clip Location Properties (W3C)
12.  Testing Nested Layer Coordinate Systems (W3C)
13. Nested Layer Visibility Relationships (W3C)
14. Relationships Among zIndex Values (W3C)
15. Dragging a Layer (W3C)
16. Methods and Properties of the Layer Object
17. Layer seek
w__w___w_.___j_a___v_a___2__s__.___c_om_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.