Javascript : Marcar Navegación (Varios Items)


/ Published in: JavaScript
Save to your folder(s)

javascript in_array object frame.
Usar:

Mediceau.Navegacion.marcar(['nav1','nav2'])
...
_--Nav 1
_--Nav 2
_--Nav 3
_--Nav 4


Copy this code and paste it in your HTML
  1. var Mediceau = document.Mediceau || {};
  2.  
  3. function MM_findObj(n, d) { //v4.01
  4. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  5. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  6. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  7. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  8. if(!x && d.getElementById) x=d.getElementById(n); return x;
  9. }
  10.  
  11. function in_array(array,elemento){
  12. for(var i in array){ if(array[i]==elemento) return true;}
  13. return false;
  14. }
  15.  
  16.  
  17. Mediceau.Navegacion = {
  18. frame: window.parent.frameNavegacion,
  19. secciones: new Array("nav_actua","nav_quienes","nav_info","nav_documentos","nav_etudes","nav_robinet","nav_salle","nav_salle_documents","nav_affiches","nav_robinet2","nav_apprendre","nav_espace"),
  20.  
  21. marcar: function(cual){
  22. for (var i=0; i < Mediceau.Navegacion.secciones.length; i++) {
  23. obj = MM_findObj(Mediceau.Navegacion.secciones[i], Mediceau.Navegacion.frame.document );
  24. if( in_array( cual, Mediceau.Navegacion.secciones[i] ) ){
  25. obj.style.display = 'block';
  26. }else{
  27. obj.style.display = 'none';
  28. }
  29. }
  30. }
  31. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.