I'm developing an android app with phonegap and I have a table with some data. When clicking on a row it should go back to index and fire a function, so I turn each row into an html `a href` with a `onclick` property. The problem is that the `href` it's working and it goes back to the index but ti doesn't fire the function. Here's the code that generates the table and the code of the function:

```
function doLocalStorage(xyz) {
        alert(xyz);
    }

<table id="hor-minimalist-b"><thead></thead><tbody></tbody></table>
    <script language="javascript">
    var table = document.getElementById('hor-minimalist-b'); // get the table element
    var tableBody = table.childNodes[1]; // get the table body
    var tableHead = table.childNodes[0]; // get the table head
    var thead = document.createElement('th');
    var row2 = document.createElement('tr'); // create a new row
    var headText = document.createTextNode('Dados');
      thead.scope = "col";
        thead.appendChild(headText);
        row2.appendChild(thead);
        tableHead.appendChild(row2);

    for (var i=0; i<len; i++) {

        var row = document.createElement('tr'); // create a new row

        var cell = document.createElement('td'); // create a new cell
        var a = document.createElement('a');
        var cellText = document.createTextNode(localStorage.getItem('key' + i));
        var xyz = localStorage.key(i);
        a.href = "index.html";
        a.onclick = "doLocalStorage(xyz);";
        a.appendChild(cellText);
        cell.appendChild(a); // append input to the new cell
        row.appendChild(cell); // append the new cell to the new row
        tableBody.appendChild(row); // append the row to table body
        }
    </script>

```

Thanks :)
['https://Stackoverflow.com/questions/12491240', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/907577/']
One you should really be using jQuery as it will take care of browser inconsistencies for you.

Two, you'll likely need to use onlick like this.

```
a.onclick = function() { doLocalStorage(xyz); };

```
Try to delete a href attribute and handle a click event with redirection `window.location.href = ('url')`. It should help.