slipperyfish Posted March 9, 2006 Share Posted March 9, 2006 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:[code]<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 && document.body.currentStyle['marginTop']) { ctop += parseInt( document.body.currentStyle['marginTop']); } 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); document.write(subject); if (boxdiv != null) { if (boxdiv.style.display=='none') { move_box(an, boxdiv); boxdiv.style.display='block'; } else boxdiv.style.display='none'; 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>'; } document.body.appendChild(boxdiv); move_box(an, boxdiv); return false;}//--></script>[/code]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> </td>[/code]at the moment you can find it [a href=\"http://www.newbiestyle.co.uk/wd/index.php\" target=\"_blank\"]HERE[/a]..HELP MUCH APPRECIATED! thanks![ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.