1

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.

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.