Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to simulate on href with ref
  2. <a href="javascript:void(0);" id="details" ref="1" title="|title" class="detail_button tips">
  3.        
  4. <a href="javascript:void(0);" id="MyId"  title="title" >1</a>
  5.  <a href="javascript:void(0);" id="MyId" ref="1" title="title" >1</a>
  6.  <a href="javascript:void(0);" id="MyId1" ref="1" title="title" >2</a>
  7.  <a href="javascript:void(0);" id="MyId2" ref="1" title="title" >3</a>
  8.  <a href="javascript:void(0);" id="MyId3" ref="1" title="title" >4</a>
  9.        
  10. aElements = document.getElementsByTagName("a");          
  11.        for (i = 0; i < aElements.length; i++) {
  12.            if (aElements[i].hasAttribute("ref") && aElements[i].hasAttribute("ref") == 1) {
  13.  
  14.                aElements[i].onclick = function () {
  15.                    alert(2);                    
  16.                }
  17.            }
  18.        }
  19.        
  20. document.getElementById('MyId').getAttribute('ref');
  21.        
  22. document.getElementById('MyId').onclick=function(){
  23.     var ref = this.getAttribute('ref');
  24.     //the ref is your value
  25.     if(ref == 1){
  26.         this.click();
  27.     }
  28. }