开发者

target="_blank" query mobile and phonegap

I have built a small app that pulls blog information via ajax into the app allowing the user to view a list of titles then click through to the main detail on a dynamically created page.

Everything is working great, but on one page the feed hold a link with target="_blank" on it. When the page is dynamically created on the iPhone or simulator, it opens the link with-in safari, without anything being clicked.

I'm guessing I need to change the link removing the 'target=_blank"' and replacing with 'rel="external"' but how to do this is proving a little difficult.

I have had a go with:

var text = $(this).find('description').text().replace(/(http[s]?:\/\/[a-zA-Z0-9\.\-\_\/\?\开发者_开发问答%\#\&\=]+)/g, "<a class='atag' href='$&'>$&</a>");

This does find the link, but replaces everything not just removing the target, which wouldn't be so bad, but the a href wraps a image, not text so reformatting this way won't work.

Any help more than welcome.

UPDATE* After a bit of digging, it is actually an iframe that is within the blog content that is opening in a new window. So looks like I need to remove a <iframe... not a target attribute.


I think this should do the trick of removing the target and replacing it with rel="external":

$('a[target="_blank"]').removeAttr("target").attr("rel", "external")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜