Question

I have list view. In which, every list item is a document(.pdf, .xls , .doc etc.). After clicking an list item, I need to open the document in the same page. So i used anchor tag without target="_BLANK". But its not working. Using target attribute, works fine and it opens in a new tab. But i need it in same tab. here is the code I used.

$('div').live('pageshow',function(event, ui){

        var parent = document.getElementById('listview');

            var listItem = document.createElement('li');
            listItem.setAttribute('id','listitem');
            listItem.innerHTML = "<a href='testdoc.doc' >My Word document</a>";
            parent.appendChild(listItem);

            var listItem = document.createElement('li');
            listItem.setAttribute('id','listitem');
            listItem.innerHTML = "<a href='Contacts.pdf' >My Pdf Document</a>";
            parent.appendChild(listItem);

            var listItem = document.createElement('li');
            listItem.setAttribute('id','listitem');
            listItem.innerHTML = "<a href='testx.xls' target='' >My Spreadsheet document</a>";
            parent.appendChild(listItem);

            var listItem = document.createElement('li');
            listItem.setAttribute('id','listitem');
            listItem.innerHTML = "<a href='Images/testImage.png'  >My Image document</a>";
            parent.appendChild(listItem);

});

I'm using JQuery-mobile alpha2 release. It works fine when i give target="" attribute in anchor tag. But its not working without it. Whats going wrong in it? Pls help. Thanks in advance.

Was it helpful?

Solution

Atlast i figured it out. I didn't use rel="external" in anchor tag. Now its working fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top