Thread Gesucht: HTML + Javascript -> "Paint"
(5 answers)
Opened by renee at 2010-04-09 20:09
ich hab hier ein projekt, wo ich das mal gemacht habe (bzw. übernommen):
Code (html): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <div id="pointer_div" onclick="point_it(event)" style = "background-image: url('bild.png'); width: 123; height: 123;"> <img src="pin.png" alt="pointer" id="cross" style="position: relative; visibility: hidden; z-index: 2;"> </div> <script language="JavaScript"> /* get click position */ function point_it(event) { pos_x = event.offsetX ? (event.offsetX) : event.pageX - document.getElementById("pointer_div").offsetLeft; pos_y = event.offsetY ? (event.offsetY) : event.pageY - document.getElementById("pointer_div").offsetTop; set_pointer(pos_x, pos_y); } /* position pin image */ function set_pointer(x,y) { var cross = document.getElementById("cross"); cross.style.left = (x - 1); cross.style.top = (y - 15); cross.style.visibility = "visible"; } </script> Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wie frage ich & perlintro brian's Leitfaden für jedes Perl-Problem |