Jump to content


This topic is now archived and is closed to further replies.


JS Menu

Recommended Posts

Hi, im new to JS and am trying to make a javascript..

I orginially downloaded a small script that places an iframe in a layer sumwhere on the page when you click a link. Iv been trying to modify it so that when the user clicks on certain links on the nav.. its opens a small box at the side.. Here's what i have so far in the script:

<script TYPE="text/javascript"><!--
function move_box(an, box)
    var cleft = 0;
    var ctop = 0;
    var obj = an;

    while (obj.offsetParent)
        cleft += obj.offsetLeft;
        ctop += obj.offsetTop;
        obj = obj.offsetParent;

    box.style.left = '300px';

    if (document.body.currentStyle &&
        ctop += parseInt(

    box.style.top = '240px'

function show_hide_box(an, width, height, borderStyle)
    var href = an.href;
    var subject = document.getElementById(title);
    var boxdiv = document.getElementById(href);
    if (boxdiv != null)
        if (boxdiv.style.display=='none')
            move_box(an, boxdiv);
        return false;

    boxdiv = document.createElement('div');

    boxdiv.setAttribute('id', href);

    boxdiv.style.display = 'block';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = '100px';
    boxdiv.style.height = '100px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.bgColor = '#ffffff';

    If (subject=="htmlcss"){
    boxdiv.innerHTML = '<center><font class="normal">Menu - HTMLCSS</font></center>';
    } else {
    boxdiv.innerHTML = '<center><font class="normal">Menu</font></center>';

    move_box(an, boxdiv);

    return false;

Im not sure if thats totally s*** or not? ..

But, where the if for the subject bit is.. ( subject=="html" ) ..
im trying to customize the content shown in the box depending upon what link is pressed.. i know its sumthing with:

[code]var subject = document.getElementById(title);[/code]

i set the title of the link (anchor) and im tryin to return what i set... any help?? Here's a typical link:

[code]             <td width="100%" bgcolor="#3E3D40" style="border: solid 2px #333333" colspan="2" onClick="return show_hide_box(this, 200, 270, '1px solid #999999');" onMouseover="this.bgColor='#7F7D7D';" onMouseout="this.bgColor='#3E3D40';">
              <center><font class="normal"><a title="htmlcss" class="navLink">HTML/CSS ></a></font></center>

at the moment you can find it [a href=\"http://www.newbiestyle.co.uk/wd/index.php\" target=\"_blank\"]HERE[/a]..


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.