Attr with Internet Explorer

Asked

Viewed 97 times

0

I have an application where I click on a table row, jquery takes the table row id, mounts a URL and put inside a href=''

The problem is I’m not getting it to work on the attr.(), I already tested on Chrome and in the Mozilla, works normal, but I need it to work in IE

PS.The application has to run on IE, and on version 8 !!!

Table (comes from an external page via Ajax)

foreach ($retorno as $valor) {
            $html.= "<tr class='codFuncionario' codigo=".$valor['codigo'].">";
                $html.= "<td>".$valor['nome']."</td>";
                $html.= "<td>".$valor['drt']."</td>";
                $html.= "<td>".$valor['cpf']."</td>";
                $html.= "<td>".$valor['setor']."</td>";
                $html.= "<td>".$valor['cargo']."</td>";
                $html.= "<td>".$valor['turno']."</td>";
            $html.= "</tr>";
        }
echo $html;

Script

$(document).on("click", ".codFuncionario", function(e){
    e.preventDefault;
    var codFuncionario = $(this).closest('tr').attr('codigo');
    //alert(codFuncionario);
    $(".a_registrar_digital").attr('href', 'registrar_digital.php?codigo='+codFuncionario);
});

Html

<a href'' class='a_registrar_difital' target='end_font' >Click Aqui</a>

Someone there has faced the same problem as me and has a solution ???

  • 2

    Which version of jQuery are you using? 2.x is not compatible with IE8.

  • I’m using the 1.11.0

  • @Tafarel_brayan How are you testing if the attr works on IE8? You are inspecting with developer tools?

  • You can put your HTML?

  • i rephrased the question by putting some other data...

  • @afsantos, yes I am using the tool for native IE developers (F12)

Show 1 more comment

2 answers

1

I do not have Internet Explorer 8 to try to reproduce the problem, but I leave some tips that may be at the origin of the problem.


Your HTML has some errors, although I think copy-paste errors for Stack Overflow. However, make sure they are present in the original.

<a href'' class='a_registrar_difital' target='end_font' >Click Aqui</a>

Missing one = in the attribute href, and the class has difital, instead of digital that jQuery is looking for.


There is a an issue in the international SO where the problem with IE8 was the developer tool needed to be manually refreshed to show the changes in the DOM document.


There is a another issue in the international SO where the use of HREF, instead of href, jQuery. I think it has to do with IE taking the path as absolute or relative to the current domain.


In the latter case, consider changing the property without jQuery, as an example.

$(document).on("click", ".codFuncionario", function(e) {
    e.preventDefault;
    var codFuncionario = $(this).closest('tr').attr('codigo');
    var caminho = 'registrar_digital.php?codigo=' + codFuncionario;
    var as = $(".a_registrar_digital");
    var i = as.length;
    while (i--) {
        as[i].href = caminho;
    }
});

0

  • Unfortunately, it doesn’t work on IE8, so I tested on 11 and it was normal.. but I need it to be in IE8, because it’s a factory system and people use IE8 there, and don’t even try to change.. rsr

  • "You don’t have my IE8 box handy"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.