469,572 Members | 1,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Javascript refresh

118 100+
Hi folks, and folkesses.

I have a piece of java script for a dynamic menu (code below).

Expand|Select|Wrap|Line Numbers
  1. <ilayer width=100% height=50 name="dep1" bgColor="#000000">
  2. <layer name="dep2" width=100% height=50>
  3. </layer>
  4. </ilayer>
  5. <div align="center" id="describe" style="background:#efefef;" onMouseover="clear_delayhide()" onMouseout="resetit(event); refresh();"></div>
  6.  
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript1.2">
  2.  
  3.  
  4. var submenu=new Array()
  5.  
  6.  
  7.  
  8. submenu[0]='<font size="2" face="Verdana"><b>| <a href="">Welcome</a> | <a href="">What we will cover</a> | </b></font>'
  9.  
  10. submenu[1]='<font size="2" face="Verdana"><b>| <a href="">Opening</a> | <a href="">Early Years</a> | <a href="">Staff</a> |</b></font>'
  11.  
  12. submenu[2]='<font size="2" face="Verdana"><b>| <a href="./html/lessons.htm" target="frame">Music Tuition</a> | <a href="lessona.htm" target="frame">Lessons</a> | </b></font>'
  13.  
  14.  
  15.  
  16.  
  17. var delay_hide=500
  18.  
  19.  
  20.  
  21. var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""
  22.  
  23. function showit(which){
  24. clear_delayhide()
  25. thecontent=(which==-1)? "" : submenu[which]
  26. if (document.getElementById||document.all)
  27. menuobj.innerHTML=thecontent
  28. else if (document.layers){
  29. menuobj.document.write(thecontent)
  30. menuobj.document.close()
  31. }
  32. }
  33.  
  34. function resetit(e){
  35. if (document.all&&!menuobj.contains(e.toElement))
  36. delayhide=setTimeout("showit(-1)",delay_hide)
  37. else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
  38. delayhide=setTimeout("showit(-1)",delay_hide)
  39. }
  40.  
  41. function clear_delayhide(){
  42. if (window.delayhide)
  43. clearTimeout(delayhide)
  44. }
  45.  
  46. function contains_ns6(a, b) {
  47. while (b.parentNode)
  48. if ((b = b.parentNode) == a)
  49. return true;
  50. return false;
  51. }
  52.  
  53. </script>
  54.  
When you take the mouse off it (onMouseout) the links/text disappears (good) but the layer stays. The only way to get rid of the layer, that I can find is to refresh the page.

The only way I could think of the refresh is by using another piece of code:
Expand|Select|Wrap|Line Numbers
  1. function refresh()
  2.                {
  3.     window.location.reload(false)
  4.                }
  5.  
but my all the links on my page target to an iframe.. When I refresh the page, with the code above, the iFrame (id = 'myiFrame') refreshes too, obviously, and goes to it's original source.

Would it be possible to refresh everything but keep the current page targetted in the iFrame, when you refresh? Or is there anything I can change in the original code to make the layers disappear on the 'resetit()' function?

Hope that was clear,

Thanks,
Sam
Oct 1 '07 #1
1 4711
acoder
16,027 Expert Mod 8TB
ilayer and layer is old code. Use div instead.

Give the div an id and hide it in the reset function by setting the style.visibility property to "hidden".
Oct 1 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Steve | last post: by
1 post views Thread by Lew | last post: by
2 posts views Thread by RootShell | last post: by
1 post views Thread by Alex Nitulescu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.