Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to click and size and image? 1

Status
Not open for further replies.

hyrogen

Programmer
Jul 10, 2003
60
GB
Hi there,
Im not to adept and JS, but Im trying to make it so you can click within an area and drag a box to a certain size and when you release the mouse a box is formed. Id would also then be nice to say click in the center of the image and move it around a defined area. Im not really sure how to tackle this one,

Any help greatfully welcome,
Thanks!
J
 
This may help you. It's an entry I wrote for a 20-line JavaScript competition in January:


Once the page has loaded (it just looks like a blank page), if you click and drag, you will see a box showing top and left coordinates, and width and height. It was designed to be an easy way to help layout web pages.

It would be a simple matter to get the finished box to convert to an image, div, or any other element of the correct size - in the onmouseup function, create the element you want, and style it with the properties stored in the mouseDragger object.

From what I remember, it works fine in IE, NN, FF, Opera, and Safari.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top