Javascript window.open function to open all urls in a json feed -


i hope able point me in right direction this, sp in advance : )

i'm needing take comes in on json feed , use javascript take embedded links - getting document.getelementsbytagname - , convert them window.open function.

i've got far with

var links = document.getelementsbytagname('a'); var len = links.length;  for(var i=0; i<len; i++) {     links[i].target = "_blank"; } 

this adds location onto url, need take url href stings like

<a href="http://myurl.com"</a> 

and return them in plain javascript call function

window.open('http://myurl.com', '_blank', 'location=yes'); 

hope makes sense, , newbie help. allister

a bit more...

karaxuna - suggestion. though reason loop function didn't return needed, that's because of how i'm trying use it.

i'm trying working phonegap mobile browser call, using inappbrowser function links open within app webview, not system browser. links need launched function window.open('http://myurl.com', '_blank', 'location=yes');

i'm using sencha touch create list item tap takes content json feed , code looks like

onmylistitemtap: function(dataview, index, target, record, e, eopts) {     dataview.up().push({         xtype: 'panel',         html: [          "<div class='news_story'>" +         "   <h4>" + record.get('title') + "</h4>" +         "   <img src='" + record.get('mobile_url') + "' />" +         "   <span>" + record.get('content') + "</span>" +         "</div>"         ],         id: 'newsdetailcard',         scrollable: {             direction: 'vertical',             directionlock: true         }     });     var links = document.getelementsbytagname('a');     var len = links.length;      for(var i=0; i<len; i++)     {         links[i].addeventlistener('click', function(){             window.open(this.href, '_blank', 'location=yes');             return false;         });     }  }, 

however, i'm not getting links opened click function you've added. not sure what's wrong. allister

for(var i=0; i<len; i++) {     links[i].addeventlistener('click', function(e){         window.open(this.href, '_blank', 'location=yes');         e.preventdefault();     }); } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -