jquery - Disable all target="_blank" links on page -


i'm building content site displayed through iframe in phonegap mobile app. content pulled cms serves content main website has mix of internal , target="_blank" links.

handling target="_blank" links proving problematic in phonegap want disable them in app website without touching content because it's used on main website.

what need jquery runs on page load, finds links target="_blank" attribute , makes links normal text.

something (how disable links before load jquery?) disables links want disable links have target="_blank" attribute, , want hide fact words links in first place:

var links = document.links; (var = 0, length = links.length; < length; i++) {     links[i].onclick = function(e) {         e = e || window.event;         e.preventdefault();     } } 

so don't want preventdefault() on link click remove links while keeping link text, , want apply target="_blank" links only.

$('a[target="_blank"]').each(function(){    $(this).removeattr('href'); }); 

or if want remove a tags

$('a[target="_blank"]').each(function(){    $(this).replacewith($(this).text()); }); 

http://jsfiddle.net/mohammadadil/kzqfd/


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -