Why is it going to the top of the page

Discussion in 'PHP' started by pedong, Jul 3, 2008.

  1. #1
    Here is my code

    echo "<td width='$colw%' height='150px' id='tddetails' bgcolor = '$bgcolor' align='center' valign = 'top' ><a href = '#' onMouseover = getunit('$unit') onclick = 'showmenu(event,linkset[0])' onMouseout='delayhidemenu()'> $blockno $unitnumber<br></a> </td>";


    When the page load all the clickable links are functioning but when I scroll down and click other links below it automatically go to the top of the page instead of showing the expected menu.. Please Help
     
    pedong, Jul 3, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Try

    Replace
    onMouseover = getunit('$unit')

    with
    onMouseover="getunit('$unit')"

    no space before or after '=' as well as enquote it. I cant see your javascript, so cant say what might be problem, if above does not work.

    regards
     
    Vooler, Jul 3, 2008 IP
  3. pedong

    pedong Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it's the same.. here is javascript code if it will help.. What I'm thinkin is how to remain it from where I clicked it?

    function showmenu(e, which, optWidth){

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

    return
    clearhidemenu()
    menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
    menuobj.innerHTML=which
    menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
    menuobj.contentwidth=menuobj.offsetWidth
    menuobj.contentheight=menuobj.offsetHeight
    eventX=ie5? event.clientX : e.clientX
    eventY=ie5? event.clientY : e.clientY
    //Find out how close the mouse is to the corner of the window
    var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
    var bottomedge=ie5? iecompattest().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.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
    else
    //position the horizontal position of the menu where the mouse was clicked
    menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
    //same concept with the vertical position
    if (bottomedge<menuobj.contentheight)
    menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
    else
    menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
    menuobj.style.visibility="visible"
    return false
    }
     
    pedong, Jul 3, 2008 IP
  4. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #4
    Oh oh I got it, replace the code you posted at first post with follwing:



    Modified:
    href='#' removed

    onclick replaced in href property
    href='javascript:showmenu(event,linkset[0])'

    I hope it helps.

    regards
     
    Vooler, Jul 3, 2008 IP
  5. pedong

    pedong Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Vooler I edited href but retained onclick and it's working..

    I've another problem this is the array

    var linkset=new Array()

    //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
    linkset[0]='<a href = "javascript:getlenk()" onMouseout="delayhidemenu()" >Hold</a>'

    linkset[0]+='<a href ="#" onMouseout="delayhidemenu()">Terms of Payment</a>'

    linkset[0]+='<a href ="#" onMouseout="delayhidemenu()">Unit Details</a>'



    What I wanted to happen is when I click the link it will open to another page with content but it shows blank page.. I use target = "_blank"
     
    pedong, Jul 3, 2008 IP
  6. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #6
    I think the problem is, you leave extra spaces before and after propery assignment. It must be strict

    Right one: href="something"
    Wrong one: href = "something"

    Fix them and let me know please. Secondly the page you are calling, does that have contents surely ?

    regards
     
    Vooler, Jul 3, 2008 IP
  7. pedong

    pedong Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok I'll fix it.. currently that's the code.. and it's working and page has content when load with the same page
     
    pedong, Jul 3, 2008 IP