Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006

    menu alle coordinate xy

    allora...dal titolo non si capisce molto....cmq...il problema è questo...
    ho trovato questo codice nel forum
    codice:
    <script> 
    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; 
    } 
    </script>
    che serve a ricavare le coordinate di un oggetto in una pagina.
    io dovrei ricavare le coordinate di un immagine e "inserirle" in quest'altro script

    codice:
    <script>
    /*** 
    This is the menu creation code - place it right after you body tag
    Feel free to add this to a stand-alone js file and link it to your page.
    **/
    
    //Menu object creation
    oCMenu=new makeCM("oCMenu") //Making the menu object. Argument: menuname
    
    //Menu properties   
    oCMenu.pxBetween=1
    oCMenu.fromLeft=5
    oCMenu.fromTop=130
    oCMenu.rows=0 
    oCMenu.menuPlacement=""
    ecc.ecc.
    al posto di 5 e 130 ovviamente.

    il buon gemello mi aveva suggerito di usare
    codice:
    oCMenu.pxBetween= getPageCoords(document.immagine).x ;
    oCMenu.fromLeft= getPageCoords(document.immagine).y ;
    ma nn funziona.
    qualcuno ha qualke consiglio da darmi???

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    strano, dovrebbe
    è possibile vedere tutta la pagina?

  3. #3
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006
    è lunghissima....la posto lo stesso???

    p.s.
    [img]nomeimmagine.gif[/img]
    questo è il codice dell'immagine....

  4. #4
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    il menù è online?
    va bene anche il link allo script originale

  5. #5
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006
    questo è il link
    http://www.dhtmlcentral.com/projects/coolmenus/?m=31

    questo è invece il link all'esempio per il codice che uso io (perchè il menu supporta diverse funzioni..io ne uso una per pescare i dati da un db)

    cmq...ora lo posto qui...sperando che non sia eccessivamente lungo

  6. #6
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006
    codice:
    <%
    Dim SQLCat, RSCat, Icat, QSSCategoria, SCatArr, CatArr, BoolCategorie, K
    %>
    <html>
    <head>
    
    <script> 
    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; 
    } 
    </script>
    	
    <style>
    BODY{
      font-family:arial,helvetica;
      font-size:12px;
    }
    code,pre{
      color:red;
    }
    /* CoolMenus 4 - default styles - do not edit */
    .clCMAbs{position:absolute; visibility:hidden; left:0; top:0}
    /* CoolMenus 4 - default styles - end */
      
    /*Style for the background-bar*/
    .clBar{position:absolute; width:10; height:10; background-color:#006699; layer-background-color:#006699; visibility:hidden}
    
    /*Styles for level 0*/
    .clLevel0,.clLevel0over{position:absolute; padding:2px; font-family:tahoma,arial,helvetica; font-size:12px; font-weight:bold}
    .clLevel0{background-color:#006699; layer-background-color:#006699; color:white;}
    .clLevel0over{background-color:#336699; layer-background-color:#336699; color:#FCCE55; cursor:pointer; cursor:hand; }
    .clLevel0border{position:absolute; visibility:hidden; background-color:#006699; layer-background-color:#006699}
    
    /*Styles for level 1*/
    .clLevel1, .clLevel1over{position:absolute; padding:2px; font-family:tahoma, arial,helvetica; font-size:11px; font-weight:bold}
    .clLevel1{background-color:#CDDBEB; layer-background-color:#CDDBEB; color:#006699;}
    .clLevel1over{background-color:#336699; layer-background-color:#336699; color:#FCCE55; cursor:pointer; cursor:hand; }
    .clLevel1border{position:absolute; visibility:hidden; background-color:#006699; layer-background-color:#006699}
    
    /*Styles for level 2*/
    .clLevel2, .clLevel2over{position:absolute; padding:2px; font-family:tahoma,arial,helvetica; font-size:10px; font-weight:bold}
    .clLevel2{background-color:#006699; layer-background-color:#006699; color:white;}
    .clLevel2over{background-color:#0099cc; layer-background-color:#0099cc; color:Yellow; cursor:pointer; cursor:hand; }
    .clLevel2border{position:absolute; visibility:hidden; background-color:#006699; layer-background-color:#006699}
    </style>
    <script language="JavaScript1.2" src="coolmenus4.js">
    /*****************************************************************************
    Copyright (c) 2001 Thomas Brattli (webmaster@dhtmlcentral.com)
    
    DHTML coolMenus - Get it at coolmenus.dhtmlcentral.com
    Version 4.0_beta
    This script can be used freely as long as all copyright messages are
    intact.
    
    Extra info - Coolmenus reference/help - Extra links to help files **** 
    CSS help: http://192.168.1.31/projects/coolmen...rence.asp?m=37
    General: http://coolmenus.dhtmlcentral.com/reference.asp?m=35
    Menu properties: http://coolmenus.dhtmlcentral.com/properties.asp?m=47
    Level properties: http://coolmenus.dhtmlcentral.com/properties.asp?m=48
    Background bar properties: http://coolmenus.dhtmlcentral.com/properties.asp?m=49
    Item properties: http://coolmenus.dhtmlcentral.com/properties.asp?m=50
    ******************************************************************************/
    </script>
    </head>
    <body>
    [img]interfaccia/SB_PROD.jpg[/img]
    
    <script>
    /*** 
    This is the menu creation code - place it right after you body tag
    Feel free to add this to a stand-alone js file and link it to your page.
    **/
    
    //Menu object creation
    oCMenu=new makeCM("oCMenu") //Making the menu object. Argument: menuname
    
    //Menu properties   
    oCMenu.pxBetween=1
    oCMenu.fromLeft=getPageCoords(document.immagine).x ;
    oCMenu.fromTop=getPageCoords(document.immagine).y ;
    oCMenu.rows=0 
    oCMenu.menuPlacement=""
                                                                 
    oCMenu.offlineRoot="file:///C|/Inetpub/wwwroot/dhtmlcentral/" 
    oCMenu.onlineRoot="" 
    oCMenu.resizeCheck=1 
    oCMenu.wait=80 
    oCMenu.fillImg="cm_fill.gif"
    oCMenu.zIndex=0
    
    //Background bar properties
    oCMenu.useBar=0
    oCMenu.barWidth="100%"
    oCMenu.barHeight="menu" 
    oCMenu.barClass="clBar"
    oCMenu.barX=0 
    oCMenu.barY=0
    oCMenu.barBorderX=0
    oCMenu.barBorderY=0
    oCMenu.barBorderClass=""
    
    //Level properties - ALL properties have to be spesified in level 0
    oCMenu.level[0]=new cm_makeLevel() //Add this for each new level
    oCMenu.level[0].width=132
    oCMenu.level[0].height=15 
    oCMenu.level[0].regClass="clLevel0"
    oCMenu.level[0].overClass="clLevel0over"
    oCMenu.level[0].borderX=0
    oCMenu.level[0].borderY=0
    oCMenu.level[0].borderClass="clLevel0border"
    oCMenu.level[0].offsetX=0
    oCMenu.level[0].offsetY=0
    oCMenu.level[0].rows=0
    oCMenu.level[0].arrow=0
    oCMenu.level[0].arrowWidth=0
    oCMenu.level[0].arrowHeight=0
    oCMenu.level[0].align="right"
    
    
    //EXAMPLE SUB LEVEL[1] PROPERTIES - You have to specify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
    oCMenu.level[1]=new cm_makeLevel() //Add this for each new level (adding one to the number)
    oCMenu.level[1].width=oCMenu.level[0].width-2
    oCMenu.level[1].height=22
    oCMenu.level[1].regClass="clLevel1"
    oCMenu.level[1].overClass="clLevel1over"
    oCMenu.level[1].borderX=1
    oCMenu.level[1].borderY=1
    oCMenu.level[1].align="right" 
    oCMenu.level[1].offsetX=-(oCMenu.level[0].width-2)/2+20
    oCMenu.level[1].offsetY=0
    oCMenu.level[1].borderClass="clLevel1border"
    
    
    //EXAMPLE SUB LEVEL[2] PROPERTIES - You have to spesify the properties you want different from LEVEL[1] OR LEVEL[0] - If you want all items to look the same just remove this
    oCMenu.level[2]=new cm_makeLevel() //Add this for each new level (adding one to the number)
    oCMenu.level[2].width=150
    oCMenu.level[2].height=20
    oCMenu.level[2].offsetX=0
    oCMenu.level[2].offsetY=0
    oCMenu.level[2].regClass="clLevel2"
    oCMenu.level[2].overClass="clLevel2over"
    oCMenu.level[2].borderClass="clLevel2border"
    
    
    //Level properties - ALL properties have to be spesified in level 0
    oCMenu.level[3]=new cm_makeLevel() //Add this for each new level
    oCMenu.level[3].width=134
    oCMenu.level[3].height=15 
    oCMenu.level[3].regClass="clLevel0"
    oCMenu.level[3].overClass="clLevel0over"
    oCMenu.level[3].borderX=0
    oCMenu.level[3].borderY=0
    oCMenu.level[3].borderClass="clLevel0border"
    oCMenu.level[3].offsetX=0
    oCMenu.level[3].offsetY=0
    oCMenu.level[3].rows=0
    oCMenu.level[3].arrow=0
    oCMenu.level[3].arrowWidth=0
    oCMenu.level[3].arrowHeight=0
    oCMenu.level[3].align="right"
    
    
    
    
    
    <%
    '---Dichiarazione variabili
    '	Dim SQLCart, RSCart, TotaleCart, SQLTipologie, RSTipologie, CartTipologia, PrezzoProdotto, PrezzoTotaleProdotto, SQLSconti, RSSconti
    
    '---Recupero i prodotti inseriti nel carrello per questa sessione
    	SQLCart = " SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"' "
    	Set RSCart = Conn.Execute(SQLCart)
    %>
    
    
    
    
    
    //Menu object creation
    oCMenu2=new makeCM("oCMenu2") //Making the menu object. Argument: menuname
    
    //Menu properties   
    oCMenu2.pxBetween=1
    oCMenu2.fromLeft=5 
    oCMenu2.fromTop=230   
    oCMenu2.rows=0 
    oCMenu2.menuPlacement=""
                                                                 
    oCMenu2.offlineRoot="file:///C|/Inetpub/wwwroot/dhtmlcentral/" 
    oCMenu2.onlineRoot="" 
    oCMenu2.resizeCheck=1 
    oCMenu2.wait=80 
    oCMenu2.fillImg="cm_fill.gif"
    oCMenu2.zIndex=0
    
    //Background bar properties
    oCMenu2.useBar=0
    oCMenu2.barWidth="100%"
    oCMenu2.barHeight="menu" 
    oCMenu2.barClass="clBar"
    oCMenu2.barX=0 
    oCMenu2.barY=0
    oCMenu2.barBorderX=0
    oCMenu2.barBorderY=0
    oCMenu2.barBorderClass=""
    
    //Level properties - ALL properties have to be spesified in level 0
    oCMenu2.level[0]=new cm_makeLevel() //Add this for each new level
    oCMenu2.level[0].width=132
    oCMenu2.level[0].height=15 
    oCMenu2.level[0].regClass="clLevel0"
    oCMenu2.level[0].overClass="clLevel0over"
    oCMenu2.level[0].borderX=0
    oCMenu2.level[0].borderY=0
    oCMenu2.level[0].borderClass="clLevel0border"
    oCMenu2.level[0].offsetX=0
    oCMenu2.level[0].offsetY=0
    oCMenu2.level[0].rows=0
    oCMenu2.level[0].arrow=0
    oCMenu2.level[0].arrowWidth=0
    oCMenu2.level[0].arrowHeight=0
    oCMenu2.level[0].align="right"
    
    
    //EXAMPLE SUB LEVEL[1] PROPERTIES - You have to specify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
    oCMenu2.level[1]=new cm_makeLevel() //Add this for each new level (adding one to the number)
    oCMenu2.level[1].width=oCMenu2.level[0].width+4
    oCMenu2.level[1].height=32
    oCMenu2.level[1].regClass="clLevel1"
    oCMenu2.level[1].overClass="clLevel1over"
    oCMenu2.level[1].borderX=1
    oCMenu2.level[1].borderY=1
    oCMenu2.level[1].align="right" 
    oCMenu2.level[1].offsetX=0
    oCMenu2.level[1].offsetY=0
    oCMenu2.level[1].borderClass="clLevel1border"
    
    
    //EXAMPLE SUB LEVEL[2] PROPERTIES - You have to spesify the properties you want different from LEVEL[1] OR LEVEL[0] - If you want all items to look the same just remove this
    oCMenu2.level[2]=new cm_makeLevel() //Add this for each new level (adding one to the number)
    oCMenu2.level[2].width=150
    oCMenu2.level[2].height=20
    oCMenu2.level[2].offsetX=0
    oCMenu2.level[2].offsetY=0
    oCMenu2.level[2].regClass="clLevel2"
    oCMenu2.level[2].overClass="clLevel2"
    oCMenu2.level[2].borderClass="clLevel2border"
    
    
    //Level properties - ALL properties have to be spesified in level 0
    oCMenu2.level[3]=new cm_makeLevel() //Add this for each new level
    oCMenu2.level[3].width=134
    oCMenu2.level[3].height=15 
    oCMenu2.level[3].regClass="clLevel0"
    oCMenu2.level[3].overClass="clLevel0over"
    oCMenu2.level[3].borderX=0
    oCMenu2.level[3].borderY=0
    oCMenu2.level[3].borderClass="clLevel0border"
    oCMenu2.level[3].offsetX=0
    oCMenu2.level[3].offsetY=0
    oCMenu2.level[3].rows=0
    oCMenu2.level[3].arrow=0
    oCMenu2.level[3].arrowWidth=0
    oCMenu2.level[3].arrowHeight=0
    oCMenu2.level[3].align="right"

  7. #7
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006
    continua....
    codice:
    /******************************************
    Menu item creation:
    myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
    *************************************/
    <%
    '*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    'ASP CODE START - READING ITEMS FROM THE DATABASE
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    Sub readItemsFromDatabase
      'The path to your database:
      Dim db,q,rs,rsarr(4,1000),menuID,mName,mLink,parent,cols,max
    	
    	db ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../mdb-database/ecom.mdb")
      
      q = "SELECT ID,Scategoria from Scategorie ORDER BY ID ASC"
      
      Set rs=Server.CreateObject("ADODB.Recordset")
      rs.CacheSize = 25 		' Cache data fetching
      rs.CursorType = 3
      rs.LockType = 3
      
      'Opening database --- --
      rs.Open q,db
      
      'Now using getRows because that's so sexy :}
     if NOT rs.EOF then
    		max = rs.recordcount - 1
    		rs.movefirst
        for i = 0 to max
    		rsarr(0,i) = rs("id")
    		rsarr(1,i) = rs("SCategoria")
    		rsarr(2,i) = "catalogo.asp?scat=" & rsarr(0,i)
    		rsarr(3,i) = 0
    		rs.movenext
        next
      else 
    		max = 0
      end if
      rs.close()
      q = "SELECT ID,Categoria,SCategoria from Categorie ORDER BY ID ASC"
      rs.Open q,db
      if NOT rs.EOF then
    		dim maxold
    		maxold = max + 1
    		max = max + rs.recordcount
    		rs.movefirst
        for i = maxold to max
    		rsarr(0,i) = rs("id") + maxold
    		rsarr(1,i) = rs("Categoria")
    		rsarr(2,i) = "catalogo.asp?scat=" & rs("Scategoria") & "&cat=" & rs("id")
    		rsarr(3,i) = rs("Scategoria")
    		rs.movenext
        next
      end if
    
    
    
      'Closing database, we don't need it anymore - we have the info in the array
      rs.close()
      Set rs = Nothing
    dim row  
    	row=0
    	do while(row<=max) 'Looping rows
        'Setting variables 
        menuID = "m" & rsarr(0,row)
        mName = rsarr(1,row)
        mLink = rsarr(2,row)
        if(mLink="null") then mLink="" 
        parent = rsarr(3,row)
        if(parent<>0) then
    			parent = "m" & parent
        else 
    			parent=""
        end if
    		'Making menu item
        Response.write("oCMenu.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "')" & vbcrlf)
      	row = row + 1
    	loop
    
    end sub
    
    
    
    
    Sub readItemsFromDatabase2
      'The path to your database:
      Dim db,q,rs,rsarr(4,1000),menuID,mName,mLink,parent,cols,max
    	
    	db ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../mdb-database/ecom.mdb")
      
    'RICAVO I DATI PER IL CARRELLO
    
      q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
      
      Set rs=Server.CreateObject("ADODB.Recordset")
      rs.CacheSize = 25 		' Cache data fetching
      rs.CursorType = 3
      rs.LockType = 3
      
      'Opening database --- --
      rs.Open q,db
      
      'Now using getRows because that's so sexy :}
    		rsarr(0,0) = 1000
    		rsarr(1,0) = "Riepilogo carrello"
    		rsarr(2,0) = "carrello.asp"
    		rsarr(3,0) = 0
     if NOT rs.EOF then
    		max = rs.recordcount
    		rs.movefirst
        for i = 1 to max
    		rsarr(0,i) = i
    		rsarr(1,i) = rs("Prodotto")
    		rsarr(2,i) = "scheda.asp?id=" & rs("idprodotto")
    		rsarr(3,i) = 1000
    		
    
    		rs.movenext
        next
    	
        
        else 
    		max = 0
      end if
    rs.close()
      q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
      rs.Open q,db
      if NOT rs.EOF then
    		dim maxold
    		maxold = max + 1
    		max = max *2
    		rs.movefirst
        for i = maxold to max
    		rsarr(0,i) = i
    		rsarr(1,i) = "Quantità: " & rs("quantita")
    		rsarr(2,i) = ""
    		rsarr(3,i) = i-maxold+1
    		rs.movenext
        next
      end if
    rs.close()
      q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
      rs.Open q,db
      if NOT rs.EOF then
    		dim maxold2
    		maxold2 = max + 1
    		max = max + rs.recordcount
    		rs.movefirst
    TotaleCart = 0
        for i = maxold2 to max
    If Session("Rivenditore") Then PrezzoProdotto = RS("RPrezzo") Else PrezzoProdotto = RS("CPrezzo")
    PrezzoTotaleProdotto = (UtilizzaPrezzo(PrezzoProdotto) * RS("Quantita"))
    		rsarr(0,i) = i
    		rsarr(1,i) = "Prezzo Tot.: " & VisualizzaPrezzo(PrezzoTotaleProdotto) & IvaNonCompresaBreve
    		rsarr(2,i) = ""
    		rsarr(3,i) = i-maxold2+1
    		TotaleCart = TotaleCart + PrezzoTotaleProdotto
    		rs.movenext
        next
      end if
    
    rs.close()
      q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
      rs.Open q,db
      if NOT rs.EOF then
    		dim maxold3
    		maxold3 = max + 1
    		max = max + rs.recordcount
    		rs.movefirst
        for i = maxold3 to max
    		rsarr(0,i) = i
    		rsarr(1,i) = "Cancella"
    		rsarr(2,i) = "prod_cancella.asp?id=" & RScart("IDProdotto") & "&idtipologia=" & RSCart("IDTipologia")
    		rsarr(3,i) = i-maxold3+1
    		rs.movenext
        next
      end if
    
    
    
    
    
    
    
    
    max = max+1
    		rsarr(0,max) = 2000
    		rsarr(1,max) = "TOTALE: " & SimboloValuta & " " & VisualizzaPrezzo(TotaleCart) & IvaNonCompresaBreve
    		rsarr(2,max) = ""
    		rsarr(3,max) = 1000
    
    max = max+1
    		rsarr(0,max) = 3000
    		rsarr(1,max) = "ORDINA"
    		rsarr(2,max) = "carrello.asp"
    		rsarr(3,max) = 1000
    
    
      'Closing database, we don't need it anymore - we have the info in the array
      rs.close()
      Set rs = Nothing
    dim row 
    	row=0
    	do while(row<=max) 'Looping rows
        'Setting variables 
        menuID = "m" & rsarr(0,row)
        mName = rsarr(1,row)
        mLink = rsarr(2,row)
        if(mLink="null") then mLink="" 
        parent = rsarr(3,row)
        if(parent<>0) then
    			parent = "m" & parent
        else 
    			parent=""
        end if
    		'Making menu item
    if mName = "Cancella" then
        Response.write("oCMenu2.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "',"""","""","""","""","""","""",""clLevel2over"")" & vbcrlf)
    else
        Response.write("oCMenu2.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "')" & vbcrlf)
    end if
      	row = row + 1
    	loop
    End Sub
    
    
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    'ASP CODE END - READING ITEMS FROM THE DATABASE
    '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    %>
    <%
    call readItemsFromDatabase
    %>
    
    //Leave this line - it constructs the menu
    
    
    oCMenu.construct()
    
    <%
    call readItemsFromDatabase2
    %>
    		
    oCMenu2.construct()
    </script>
    
    
    </body>
    </html>

  8. #8
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    sì, ma il lato server non interessa in questo momento,
    era meglio postare un output-tipo

    hai provato a spostare un po' l' immagine?
    praticamente è il primo elemento del documento

    x il resto mi sembra che la logica venga rispettata:
    il costruttore viene richiamato dopo che è stata inserita l' immagine
    ed è già presente lo script per rilevarne la posizione

  9. #9
    Utente bannato
    Registrato dal
    Feb 2000
    Messaggi
    2,006
    non è il primo elemento perchè in realtà questo file io lo includo in un altro....
    non so che fare :master:
    anche perchè l'immagine la vedo al punto giusto del documento....

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 © 2024 vBulletin Solutions, Inc. All rights reserved.