Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 18 su 18

Discussione: selezionare un area

  1. #11
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    ho provato anche cosi ma non funziona, event non è definito:

    function getMouseCoords(event) {
    //if(!e) e = window.event;
    var coords = {x: 0, y: 0};
    coords.layerX = event.layerX -1;
    coords.layerY = event.layerY -1;
    if(navigator.appName == "Netscape") {
    coords.layerX += window.pageXOffset;
    coords.layerY += window.pageYOffset;
    }
    if (navigator.appVersion.indexOf("MSIE") != -1){
    if (navigator.appVersion.indexOf("Mac") == -1){
    coords.layerXx += document.body.scrollLeft;
    coords.layerY += document.body.scrollTop;
    }
    }
    return coords


    come mai?


    Lo script completo funzionante su explorer è il seguente:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT>
    document.onselectstart = new Function("return true;");
    document.ondragstart = new Function("return false;");
    r_on = false;
    x0=0;
    y0=0;
    x1=0;
    y1=0;
    iw=0;
    ih=0;
    il=0;
    it=0;
    bordo=1 *2;

    function getPageCoords(element) {
    // thanks to 'Martin Honnen' for this function
    var coords = {x: 0, y: 0};
    while (element) {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
    }
    return coords;
    }

    function getMouseCoords(e) {
    if(!e) e = window.event;
    var coords = {x: 0, y: 0};
    coords.x = e.x -1;
    coords.y = e.y -1;
    if(navigator.appName == "Netscape") {
    coords.x += window.pageXOffset;
    coords.y += window.pageYOffset;
    }
    if (navigator.appVersion.indexOf("MSIE") != -1){
    if (navigator.appVersion.indexOf("Mac") == -1){
    coords.x += document.body.scrollLeft;
    coords.y += document.body.scrollTop;
    }
    }
    return coords
    }

    function r_misura(obj) {
    iw = obj.width;
    ih = obj.height
    p = getPageCoords(obj);
    il = p.x;
    it = p.y;
    obj.alt='t='+it+' l='+il+' w='+iw+' h='+ih
    }

    function r_start(obj) {
    p = getMouseCoords();
    x0 = p.x -1;
    y0 = p.y -1;
    x1 = x0;
    y1 = y0;
    r_on = true;

    d = document.re1.style;
    d.top=y0;
    d.left=x0;
    d.height=0;
    d.width=0;
    d.display='none';
    }

    function r_move(obj) {
    if (r_on) {
    p = getMouseCoords()
    x1 = p.x;
    y1 = p.y;
    // x1 = (x1<x0)?x1-1:x1;
    // y1 = (y1<y0)?y1-1:y1;

    d = document.re1.style;
    // riordino e correggo le coordinate per l'immagine
    ix0 = (x1<x0)?x1-1:x0;
    iy0 = (y1<y0)?y1-1:y0;
    ix1 = (x1>x0)?x1:x0;
    iy1 = (y1>y0)?y1:y0;
    // limito l'escursione
    ix0 = (ix0<il)?il:ix0;
    iy0 = (iy0<it)?it:iy0;
    ix1 = (ix1>iw+il)?iw+il:ix1;
    iy1 = (iy1>ih+it)?ih+it:iy1;
    if (ix1-ix0>bordo && iy1-iy0>bordo) {
    d.display=''
    d.top=iy0;
    d.left=ix0;
    d.width=ix1-ix0-bordo;
    d.height=iy1-iy0-bordo;
    } else {
    d.display='none'
    }

    f = document.misure;
    f.myTop.value=y0-it;
    f.myLeft.value=x0-il;
    f.myBottom.value=y1-it;
    f.myRight.value=x1-il;
    f.myHeight.value=y1-y0;
    f.myWidth.value=x1-x0;
    }
    }

    function r_stop() {
    r_on = false;
    }

    </SCRIPT>

    <META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD>
    <BODY bgColor=cyan>[img]index_file/image2.jpg[/img]
    [img]index_file/ghost.gif[/img]
    <HR>

    <FORM name=misure>Top:<INPUT size=3 name=myTop> Left:<INPUT size=3 name=myLeft>
    Bottom:<INPUT size=3 name=myBottom> Right:<INPUT size=3 name=myRight>
    Height:<INPUT size=3 name=myHeight> Width:<INPUT size=3 name=myWidth> <INPUT onclick="x0=0;y0=0;document.re1.style.display='non e'" type=reset value=Clear>
    </FORM></BODY></HTML>

  2. #12
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    nessuno ..proprio nessuno puo aiutarmni?..purtroppo l' applicativo gira su linux e usano mozilla...che fare?

    grazie

  3. #13
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    nello script c'è in effetti la parte di codice riferita a nescape..ora io di mozilla ho la 1.5, se faccio navigator.appname di js mi restituisce Nescape..non capisco perchè non funziona...

  4. #14
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Purtroppo (per te) non ho netscape... ma posso provare ad applicare le informazioni che Xinod ti ha linkato ...

    function getMouseCoords(e) {
    if(!e) e = window.event;
    var coords = {x: 0, y: 0};
    if(navigator.appName == "Netscape") {
    coords.x = e.pageX + window.pageXOffset -1;
    coords.y = e.pageY + window.pageYOffset -1;
    } else {
    coords.x = e.x -1;
    coords.y = e.y -1;
    }
    if (navigator.appVersion.indexOf("MSIE") != -1){
    if (navigator.appVersion.indexOf("Mac") == -1){
    coords.x += document.body.scrollLeft;
    coords.y += document.body.scrollTop;
    }
    }
    return coords
    }

    ma, come dicevo prima, non lo posso testare...

    ciao
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  5. #15
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    Ciao br1,

    non funziona...a me serve solo che vada su mozilla...ma niente da fare errore:

    coords.x = e.pageX + window.pageXOffset -1;

    a questa riga: e has no properties..

    Cavolo non rieco in nessun modo a farlo funzionare su mozilla...non va eppure l' evento in mozilla si gestisce cosi..

    grazie

    PS riposto il codice modificato:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT>
    document.onselectstart = new Function("return true;");
    document.ondragstart = new Function("return false;");
    r_on = false;
    x0=0;
    y0=0;
    x1=0;
    y1=0;
    iw=0;
    ih=0;
    il=0;
    it=0;
    bordo=1 *2;

    function getPageCoords (element) {
    var coords = {x: 0, y: 0};
    while (element) {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
    }
    return coords;
    }

    function r_misura(obj) {
    iw = obj.width;
    ih = obj.height
    p = getPageCoords(obj);
    il = p.x;
    it = p.y;
    obj.alt='t='+it+' l='+il+' w='+iw+' h='+ih
    }
    function getMouseCoords(e) {
    if(!e) e = window.event;
    var coords = {x: 0, y: 0};
    if(navigator.appName == "Netscape") {
    coords.x = e.pageX + window.pageXOffset -1;
    coords.y = e.pageY + window.pageYOffset -1;
    } else {
    coords.x = e.x -1;
    coords.y = e.y -1;
    }
    if (navigator.appVersion.indexOf("MSIE") != -1){
    if (navigator.appVersion.indexOf("Mac") == -1){
    coords.x += document.body.scrollLeft;
    coords.y += document.body.scrollTop;
    }
    }
    return coords
    }

    function r_start(obj) {
    p = getMouseCoords();
    x0 = p.x -1;
    y0 = p.y -1;
    x1 = x0;
    y1 = y0;
    r_on = true;

    d = document.re1.style;
    d.top=y0;
    d.left=x0;
    d.height=0;
    d.width=0;
    d.display='none';
    }

    function r_move(obj) {
    if (r_on) {
    p = getMouseCoords()
    x1 = p.x;
    y1 = p.y;
    // x1 = (x1<x0)?x1-1:x1;
    // y1 = (y1<y0)?y1-1:y1;

    d = document.re1.style;
    // riordino e correggo le coordinate per l'immagine
    ix0 = (x1<x0)?x1-1:x0;
    iy0 = (y1<y0)?y1-1:y0;
    ix1 = (x1>x0)?x1:x0;
    iy1 = (y1>y0)?y1:y0;
    // limito l'escursione
    ix0 = (ix0<il)?il:ix0;
    iy0 = (iy0<it)?it:iy0;
    ix1 = (ix1>iw+il)?iw+il:ix1;
    iy1 = (iy1>ih+it)?ih+it:iy1;
    if (ix1-ix0>bordo && iy1-iy0>bordo) {
    d.display=''
    d.top=iy0;
    d.left=ix0;
    d.width=ix1-ix0-bordo;
    d.height=iy1-iy0-bordo;
    } else {
    d.display='none'
    }

    f = document.misure;
    f.myTop.value=y0-it;
    f.myLeft.value=x0-il;
    f.myBottom.value=y1-it;
    f.myRight.value=x1-il;
    f.myHeight.value=y1-y0;
    f.myWidth.value=x1-x0;
    }
    }

    function r_stop() {
    r_on = false;
    }

    </SCRIPT>

    <META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD>
    <BODY bgColor=cyan>[img]index_file/image2.jpg[/img]
    [img]index_file/ghost.gif[/img]
    <HR>

    <FORM name=misure>Top:<INPUT size=3 name=myTop> Left:<INPUT size=3 name=myLeft>
    Bottom:<INPUT size=3 name=myBottom> Right:<INPUT size=3 name=myRight>
    Height:<INPUT size=3 name=myHeight> Width:<INPUT size=3 name=myWidth> <INPUT onclick="x0=0;y0=0;document.re1.style.display='non e'" type=reset value=Clear>
    </FORM></BODY></HTML>

  6. #16
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    nessuno con mozilla ed esperienza in js puo aiutarmi?

    Non so proprio come risolverlo, sto provando in tutti i modi..

    grazie:

  7. #17
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    non c'è verso...

  8. #18
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,093
    Allora, l' ultima versione è la seguente:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <SCRIPT>
    document.onselectstart = new Function("return true;");
    document.ondragstart = new Function("return false;");
    r_on = false;
    x0=0;
    y0=0;
    x1=0;
    y1=0;
    iw=0;
    ih=0;
    il=0;
    it=0;
    bordo=1 *2;

    function getPageCoords (element) {
    var coords = {x: 0, y: 0};
    while (element) {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
    element = element.offsetParent;
    }
    return coords;
    }

    function r_misura(obj) {
    iw = obj.width;
    ih = obj.height
    p = getPageCoords(obj);
    il = p.x;
    it = p.y;
    obj.alt='t='+it+' l='+il+' w='+iw+' h='+ih
    }


    function getMousePosition(e){
    if(!e) e = window.event;
    var coords = {x: 0, y: 0};
    if(navigator.appName == "Netscape") {
    coords.x = e.pageX + window.pageXOffset -1;
    coords.y = e.pageY + window.pageYOffset -1;
    } else {
    coords.x = e.x -1;
    coords.y = e.y -1;
    }
    if (navigator.appVersion.indexOf("MSIE") != -1){
    if (navigator.appVersion.indexOf("Mac") == -1){
    coords.x += document.body.scrollLeft;
    coords.y += document.body.scrollTop;
    }
    }
    alert(coords.x, coords.y);
    //return coords
    }


    function r_start(obj) {
    p = getMousePosition();
    x0 = p.x -1;
    y0 = p.y -1;
    x1 = x0;
    y1 = y0;
    r_on = true;

    d = document.re1.style;
    d.top=y0;
    d.left=x0;
    d.height=0;
    d.width=0;
    d.display='none';
    }

    function r_move(obj) {
    if (r_on) {
    p = getMouseCoords()
    x1 = p.x;
    y1 = p.y;
    // x1 = (x1<x0)?x1-1:x1;
    // y1 = (y1<y0)?y1-1:y1;

    d = document.re1.style;
    // riordino e correggo le coordinate per l'immagine
    ix0 = (x1<x0)?x1-1:x0;
    iy0 = (y1<y0)?y1-1:y0;
    ix1 = (x1>x0)?x1:x0;
    iy1 = (y1>y0)?y1:y0;
    // limito l'escursione
    ix0 = (ix0<il)?il:ix0;
    iy0 = (iy0<it)?it:iy0;
    ix1 = (ix1>iw+il)?iw+il:ix1;
    iy1 = (iy1>ih+it)?ih+it:iy1;
    if (ix1-ix0>bordo && iy1-iy0>bordo) {
    d.display=''
    d.top=iy0;
    d.left=ix0;
    d.width=ix1-ix0-bordo;
    d.height=iy1-iy0-bordo;
    } else {
    d.display='none'
    }

    f = document.misure;
    f.myTop.value=y0-it;
    f.myLeft.value=x0-il;
    f.myBottom.value=y1-it;
    f.myRight.value=x1-il;
    f.myHeight.value=y1-y0;
    f.myWidth.value=x1-x0;
    }
    }

    function r_stop() {
    r_on = false;
    }

    if(document.layers) document.captureEvents(Event.CLICK);
    document.onclick=getMousePosition;
    </SCRIPT>

    <META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD>
    <BODY bgColor=cyan>[img]index_file/image2.jpg[/img]
    [img]index_file/ghost.gif[/img]
    <HR>

    <FORM name=misure>Top:<INPUT size=3 name=myTop> Left:<INPUT size=3 name=myLeft>
    Bottom:<INPUT size=3 name=myBottom> Right:<INPUT size=3 name=myRight>
    Height:<INPUT size=3 name=myHeight> Width:<INPUT size=3 name=myWidth> <INPUT onclick="x0=0;y0=0;document.re1.style.display='non e'" type=reset value=Clear>
    </FORM></BODY></HTML>



    ma non funzeca...

    allora la getmouseposition funziona se clicco con il mous, ma se provo tenendo premuto il bottone del mouse a trascinarlo sull' img per selezionarne una parte, mi ritrovo l' errore e il cerchiolino di "divieto" come cursore....

    non capisco..nessuno mi puo aiutare ?...non riesco ad uscirne..

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.