Avatar billede tobby Nybegynder
23. juni 2002 - 00:59 Der er 1 kommentar og
1 løsning

Dynamisk tree-folder menu med pop-menu...

Følgende giver fejlen "'menuobj' is not an object" i linien:

menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

Koden:

<!-- #include file="include/check_type.asp" -->
<%
Response.Buffer = True

Query = "SELECT * FROM Menu ORDER By Navn DESC"

Set Menu = Server.CreateObject("ADODB.RecordSet")
Menu.Open Query, Connect, 0

Function ShowReplies(bID, Conn)
    Dim RS

    Query = "SELECT ID, Titel, ParentID, Childs FROM Docs WHERE ParentID = '" & bID & "' ORDER BY Titel"
   
    Set RS = Server.CreateObject("ADODB.RecordSet")
    RS.Open Query, Connect, 0
   
    If NOT RS.EOF Then
        FoundSome = True
        Response.Write("<ul>")
    End If

    Childs = 1
    Do While Not RS.EOF
        if RS("Childs") = "Yes" Then
            Childs = Childs + 1
            Response.Write("<li id=""foldheader""><a href=""#"" onMouseover=""showmenu(event, GetVars( '" & RS("ID") & "', '" & RS("ID") & "' ) )"" onMouseout=""delayhidemenu()"" style=""text-decoration: none;"">" & RS("Titel") & "</a></li>")
            Response.Write("<ul id=""foldinglist"" style=""display:none"" style=&{head};>")
            ShowReplies rs("ID"), Conn
        else
            Response.Write("<li><a href=""#"" onMouseover=""showmenu(event, GetVars( '" & RS("ID") & "', '" & RS("ID") & "' ) )"" onMouseout=""delayhidemenu()"" style=""text-decoration: none;"">" & RS("Titel") & "</a></li>")
            ShowReplies rs("ID"), Conn
        end if
    RS.MoveNext
    Loop

    If FoundSome Then
        Response.Write("</ul>")
    End If
   
    if Childs > 1 Then
        k = 1
        do until k = Childs + 1
            Response.Write("</ul>")
            k = k + 1
        loop
    end if
   

    RS.Close
    Set RS = Nothing

End Function
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK rel="stylesheet" type="text/css" href="include/style.css">
<style>
<!--

.menuskin{
position:absolute;
width:80px;
background-color:menu;
border:1px solid black;
font:normal 10px Verdana;
line-height:12px;
z-index:100;
visibility:hidden;
}

.menuskin a{
text-decoration:none;
color:black;
padding-left:2px;
padding-right:2px;
}

#mouseoverstyle{
background-color:highlight;
}

#mouseoverstyle a{
color:white;
}

#foldheader{cursor:pointer;cursor:hand ; font-weight:bold ;
list-style-image:url(images/fold.gif)}
#foldinglist{list-style-image:url(images/list.gif)}
//-->
</style>
<script language="JavaScript1.2">

function GetVars(MenuID, DocID){
    var bygStreng = '<div class="menuitems"><a href="_edit.asp?Mode=New&ParentID=' +MenuID +'" target="Main">Opret</a></div>';
    bygStreng += '<div class="menuitems"><a href="editor/edit.asp?Mode=Edit&ID=' +DocID +'" target="Main">Rediger</a></div>';
    bygStreng += '<div class="menuitems"><a href="_edit.asp?Mode=Delete&ID=' +DocID +'" target="Main">Slet</a></div>';
    bygStreng += '<div class="menuitems"><a href="_edit.asp?Mode=Up&ID=' +DocID +'" target="Main">Ryk op</a></div>';
    bygStreng += '<div class="menuitems"><a href="_edit.asp?Mode=Down&ID=' +DocID +'" target="Main">Ryk ned</a></div>';
    return bygStreng;
}


//Pop-it menu- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]= GetVars

linkset[1]='<div class="menuitems"><a href="http://msnbc.com">MSNBC</a></div>'
linkset[1]+='<div class="menuitems"><a href="http://cnn.com">CNN</a></div>'
linkset[1]+='<div class="menuitems"><a href="http://abcnews.com">ABC News</a></div>'
linkset[1]+='<div class="menuitems"><a href="http://www.washingtonpost.com">Washington Post</a></div>'

////No need to edit beyond here

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

function showmenu(e,which){

if (!document.all&&!document.getElementById&&!document.layers)
return

clearhidemenu()

menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

if (ie4||ns6)
menuobj.innerHTML=which
else{
menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
menuobj.document.close()
}

menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height
eventX=ie4? event.clientX : ns6? e.clientX : e.x
eventY=ie4? event.clientY : ns6? e.clientY : e.y

//Find out how close the mouse is to the corner of the window
var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX

//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? window.pageYOffset+eventY-menuobj.contentheight : eventY-menuobj.contentheight
else
menuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY
menuobj.thestyle.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
}

function dynamichide(e){
if (ie4&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
if (ie4||ns6||ns4)
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

function highlightmenu(e,state){
if (document.all)
source_el=event.srcElement
else if (document.getElementById)
source_el=e.target
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
else{
while(source_el.id!="popmenu"){
source_el=document.getElementById? source_el.parentNode : source_el.parentElement
if (source_el.className=="menuitems"){
source_el.id=(state=="on")? "mouseoverstyle" : ""
}
}
}
}

if (ie4||ns6)
document.onclick=hidemenu

//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var head="display:''"
img1=new Image()
img1.src="images/fold.gif"
img2=new Image()
img2.src="images/open.gif"

var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
cur.style.listStyleImage="url(images/open.gif)"
}
else{
foldercontent.style.display="none"
cur.style.listStyleImage="url(images/fold.gif)"
}
}
}

if (ie4||ns6)
document.onclick=checkcontained

//-->
</script>
</HEAD>
<BODY topmargin=0 leftmargin=0>
<font face="Verdana">
<ul>
<%
do until Menu.EOF

    Response.Write("<li id=""foldheader"">" & Menu("Navn") & "</li>")
    Response.Write("<ul id=""foldinglist"" style=""display:none"" style=&{head};>")
   
    Query = "SELECT ID, ParentID, Titel, Childs FROM Docs WHERE ParentID = '" & Menu("ID") & "' ORDER BY Titel"
   
    Set bRS = Server.CreateObject("ADODB.RecordSet")
    bRS.Open Query, Connect, 0
   
    Do While NOT bRS.EOF
   
        if bRS("Childs") = "Yes" Then
            Response.Write("<li id=""foldheader""><a href=""#"" onMouseover=""showmenu(event, GetVars( '" & bRS("ID") & "', '" & bRS("ID") & "' ) )"" onMouseout=""delayhidemenu()"" style=""text-decoration: none;"">" & bRS("Titel") & "</a></li>")
            Response.Write("<ul id=""foldinglist"" style=""display:none"" style=&{head};>")
        else
            Response.Write("<li><a href=""#"" onMouseover=""showmenu(event, GetVars( '" & bRS("ID") & "', '" & bRS("ID") & "' ) )"" onMouseout=""delayhidemenu()"" style=""text-decoration: none;"">" & bRS("Titel") & "</a></li>")
        end if
       
        Call Showreplies(bRs("ID"), Conn)
           
    bRS.MoveNext
    Loop

    bRS.Close
    Set bRS = Nothing
   
Response.Write("</ul>")
Menu.MoveNext
Loop
%>
</BODY>
</HTML>
<%
Menu.Close
Set Menu = Nothing
%>
Avatar billede =maddog= Nybegynder
23. juni 2002 - 07:49 #1
du har ikke noget objekt med id="popmenu". så det er rimelig klart at document.all.popmenu, document.getElementById('popmenu') osv ikke giver mening.
Avatar billede tobby Nybegynder
23. juni 2002 - 13:38 #2
=maddog=> du har fuldstændig ret! - mange tak!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester