(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
10. 02. 2006. | #1 |
expert
Master
Datum učlanjenja: 20.12.2005
Poruke: 730
Hvala: 0
0 "Hvala" u 0 poruka
|
event.clientX u FF
Ajde pomozite malo. Radi i u Operi i u IE, ali u FF ne radi, znam da ovo mozda nije bas najbolji (mozda je i najgori) nacin da se ovo uradi:
Kôd:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>maestitia.net : index : Credits</title> <script type="text/javascript"> function showpopup(id) { var popup=document.getElementById(id); popup.style.visibility="visible"; popup.style.top=event.clientY+"px"; popup.style.left=event.clientX+"px"; } function hidepopup(id) { var popup=document.getElementById(id); popup.style.visibility="hidden"; } </script> <style type="text/css"> #popup { color:white; background:black; border:1px solid red; } </style> <body> <div id="popup" style="position:absolute;visibility:hidden">Tekst u popupu</div> <p style="text-align:center"> <a href="http://example.com" onmousemove="showpopup('popup')" onmouseout="hidepopup('popup');">Link</a> </p> </body> </html> |
10. 02. 2006. | #2 |
Dejan Katašić
Wrote a book
Datum učlanjenja: 10.06.2005
Lokacija: Novi Sad
Poruke: 1.017
Hvala: 129
86 "Hvala" u 43 poruka
|
"event is not defined" ...
|
10. 02. 2006. | #3 |
Dejan Katašić
Wrote a book
Datum učlanjenja: 10.06.2005
Lokacija: Novi Sad
Poruke: 1.017
Hvala: 129
86 "Hvala" u 43 poruka
|
Evo, da ti vratim malo iskasapljen kod, ali radi (definitivno mu treba još šminke :-)))
Kôd:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>maestitia.net : index : Credits</title> <script type="text/javascript"> function mm(e) { if (typeof (event) == 'undefined') var event = e; var popup=document.getElementById('popup'); popup.style.visibility="visible"; popup.style.top=event.clientY+"px"; popup.style.left=event.clientX+"px"; } function hidepopup(id) { var popup=document.getElementById(id); popup.style.visibility="hidden"; } </script> <style type="text/css"> #popup { color:white; background:black; border:1px solid red; } </style> <body onload="var l = document.getElementById ('ll'); l.onmousemove = mm; l.onmouseover = mm;"> <div id="popup" style="position:absolute;visibility:hidden">Tekst u popupu</div> <p style="text-align:center"> <a id="ll" href="http://example.com" onmouseout="hidepopup('popup');">Link</a> </p> </body> </html> Poslednja izmena od noviKorisnik : 10. 02. 2006. u 12:00. |
10. 02. 2006. | #4 |
Ivan Dilber
Sir Write-a-Lot
|
nema neke veze sa ovim javascriptom, ali mozda nekom ustedi malo muka:
izbegavajte <?xml deklaraciju pre doctype-a, nije neophodna, pogotovo ne za transitional dokumente, a sludi IE i ubaci ga u quirks mod...
__________________
Leadership is the art of getting people to want to do what you know must be done. |
10. 02. 2006. | #5 |
expert
Master
Datum učlanjenja: 20.12.2005
Poruke: 730
Hvala: 0
0 "Hvala" u 0 poruka
|
@nK
Aha, znaci ovako: Kôd:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>maestitia.net : index : Credits</title> <script type="text/javascript"> function mm(e) { var evt=e; if (typeof (e) != 'object') evt = event; var popup=document.getElementById(this.id+'popup'); popup.style.visibility="visible"; popup.style.top=evt.clientY+10+"px"; popup.style.left=evt.clientX+10+"px"; } function hidepopup(element) { var popup=document.getElementById(element.id+"popup"); popup.style.visibility="hidden"; } function init() { var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].className.match(/\bpopup\b/)) { links[i].onmousemove=mm; links[i].onmouseover=mm; } } } </script> <style type="text/css"> div.popup { color:white; background:black; border:1px solid red; } </style> <body onload="init()"> <p> <a class="popup" id="A1" href="http://google.com" onmouseout="hidepopup(this);">Link</a><div id="A1popup" class="popup" style="position:absolute;visibility:hidden">Google!</div> <br /> <a class="popup" id="A2" href="http://yahoo.com" onmouseout="hidepopup(this);">Link</a><div id="A2popup" class="popup" style="position:absolute;visibility:hidden">Yahoo!</div> <br /> <a href="http://www.devprotalk.com">Link to DPT</a> </p> </body> </html> Poslednja izmena od bojan_bozovic : 10. 02. 2006. u 15:08. |
10. 02. 2006. | #6 |
Dejan Katašić
Wrote a book
Datum učlanjenja: 10.06.2005
Lokacija: Novi Sad
Poruke: 1.017
Hvala: 129
86 "Hvala" u 43 poruka
|
Da, možeš još lepo da očistiš taj ... xml, html, štogod :-) ... onmouseover definiši isto pri inicijaciji. Referenca na popup u hidepopup onda ide isto kao i u showpopup (ipak bolje ime no mm :-))) ... i izbaci inline style sa divova.
(... jedino što je Opera pametna pa stavlja preko svoje balončiće s adresom linka, to valjda ne može da šteti, hehehe |
10. 02. 2006. | #7 |
banned
Professional
Datum učlanjenja: 04.06.2005
Poruke: 371
Hvala: 0
738 "Hvala" u 83 poruka
|
Sada gledam malo ovo, javiće se problemi ukoliko se do linka scroll-uje. Stavi npr sa mm funkciju ovako:
Kôd:
function mm(e) { var evt=e; if (typeof (e) != 'object') evt = event; var popup=document.getElementById(this.id+'popup'); if(evt.pageX || evt.pageY){ posX = evt.pageX; posY = evt.pageY; } else if(evt.clientX || evt.clientY){ posX = evt.clientX + document.getElementsByTagName('body')[0].scrollLeft; posY = evt.clientY + document.getElementsByTagName('body')[0].scrollTop; } popup.style.visibility="visible"; popup.style.top=posY+10+"px"; popup.style.left=posX+10+"px"; }
__________________
Don't look at me; I'm lost too. “If you can't dazzle them with brilliance, baffle them with bul*s**t.” |
11. 02. 2006. | #8 |
expert
Master
Datum učlanjenja: 20.12.2005
Poruke: 730
Hvala: 0
0 "Hvala" u 0 poruka
|
Kôd:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>popup test</title> <script type="text/javascript"> function show_popup(e) { var evt=e; if (typeof (e) != 'object') evt = event; var popup=document.getElementById(this.id+'popup'); var x,y; if (self.pageYOffset) // all except Explorer { x = self.pageXOffset; y = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict { x = document.documentElement.scrollLeft; y = document.documentElement.scrollTop; } else if (document.body) // all other Explorers { x = document.body.scrollLeft; y = document.body.scrollTop; } popup.style.visibility="visible"; popup.style.top=y+evt.clientY+10+"px"; popup.style.left=x+evt.clientX+10+"px"; } function hide_popup() { var popup=document.getElementById(this.id+"popup"); popup.style.visibility="hidden"; } function init(){ var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].className.match(/\bpopup\b/)) { links[i].onmousemove=show_popup; links[i].onmouseover=show_popup; links[i].onmouseout=hide_popup; } } } </script> <style type="text/css"> div.popup { color:white; background:black; border:1px solid red; position:absolute; visibility:hidden; } </style> <body onload="init()"> <p> <a class="popup" id="A1" href="http://example.com">Link</a><div id="A1popup" class="popup">Google!</div> <br /> <a class="popup" id="A2" href="http://yahoo.com">Link</a><div id="A2popup" class="popup">Yahoo!</div> <br /> <a href="http://www.devprotalk.com">DPT</a> </p> </body> </html> @nK Hocemo li da pisemo copyright za ovo Poslednja izmena od bojan_bozovic : 11. 02. 2006. u 02:53. |
11. 02. 2006. | #9 |
Goran Pilipović
Sir Write-a-Lot
|
Ako može jedan predlog za poboljšanje?
Napraviti sve kompletno automatski. Znači ne dodavati te silne popup div-ove (zamisli 30-ak ili 100 linkova na strani) nego čitati iz title="xxx" za svaki <a></a> i imati samo 1 popup koji se premešta po potrebi umesto za svaki link posebno. I to je 100% SEO a ne moraš ništa da brineš osim da dodaš title="xxx" za svaki link, što je ionako preporučljivo.
__________________
Goran Pilipović a.k.a. Ugly Fingers Bradley f.k.a. bluesman I don't always know what I'm talking about but I know I'm right! |
11. 02. 2006. | #10 |
expert
Master
Datum učlanjenja: 20.12.2005
Poruke: 730
Hvala: 0
0 "Hvala" u 0 poruka
|
@bluesman
Imam takvu skriptu, ali mislim da pretrazivac ignorise title property. Neka me neko ispravi ako gresim, zato sam krenuo u ovo. Evo ti je ovde http://www.dustindiaz.com/sweet-titles-finalized/ Evo ti html: <div class="popup" id="A1popup">This is link to DPT forums, webdevelopment community.</div><a class="popup" id="A1">http://www,devprotalk.com</a> i Google ce da vidi bas sta treba, kako treba. Ovako moze sa document.GetElementById(this.id+"popup").innerHTML jos da se ubacuju slike dinamicki sa XMLHttpRequest (uz preload loading.gif ) Mnogo fleksibilnije resenje. Poslednja izmena od bojan_bozovic : 11. 02. 2006. u 03:05. |
|
|
Slične teme | ||||
Tema | Početna poruka teme | Forum | Odgovori | Poslednja poruka |
Kohana display event | ivanhoe | Web aplikacije, web servisi i software | 4 | 30. 09. 2009. 00:27 |
Lose Organizovan Vista Event | Dejan Bizinger | Opušteno | 5 | 01. 03. 2007. 19:46 |
<select> onClose event | godza | (X)HTML, JavaScript, DHTML, XML, CSS | 14 | 23. 07. 2006. 20:04 |