开发者

Problem in loading a document in the same page using href="" in Jquery-mobile

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 a开发者_高级运维nd 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜