javascript - jquery - disable href inside a html frame from the page -


i have set of html elements selected javascript function , want pass jquery , disable html links in list.please let me know , how achieve this.

var links = window.frames[1].document.getelementsbytagname("a"); 

if normal single html page can select links using below jquery function , disable links. have html frames associated this, jquery not able select frame element.

so have selected using javascript thats "links".

$("a").click(function (event) {         event.preventdefault();     }); 

html :

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">  <html> <head>     <meta http-equiv="content-type" content="text/html;charset=utf-8">     <meta http-equiv="pragma" content="no-cache">     <meta http-equiv="expires" content="-1">  </head> <body> <div id="wrapper">     <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">         <div class="navbar-default sidebar" role="navigation">             <div class="sidebar-nav navbar-collapse">                 <ul class="nav" id="side-menu">                     <li>                     </li>                     <li>                         <a id ="test" href="/frame1.html" target="detail"><i class="demo-icon icon-chart-line fa-fw"></i> status<span class="demo-icon icon-right-open-1"></span></a>                     </li>                     <li>                         <a href="/frame2.html" target="detail"><i class="demo-icon icon-flow-tree fa-fw"></i> setup<span class="demo-icon icon-right-open-1"></span></a>                     </li>                  </ul>                 <div id="navfooter">                      <div id="copyright-loader">                         <!--<i class="demo-icon icon-spin6 animate-spin" style='font-size:6em; color:#31bbd6;'></i> <br><br>-->                         <img alt="logo" class="img-responsive" src="../images/logo.jpg" />                     </div>                      <br clear='all' /> <br />                  </div>              </div>         </div>     </nav> </div> <p>&nbsp;</p> </body> </html> 

thanks

add css style pointer-event:none anchor tag.

document.getelementsbytagname("a")[0].style.pointerevents = "none";

test chrome , firefox work fine. in ie not work

or remove href attribute anchor tag

document.getelementsbytagname("a")[0].removeattribute("href");


Comments