0

I am using applicationcraft.com and have the following test app http://acft.ws/tyjk

I have managed to stop the click firing and opening a new window. I need to capture the url of the clicked link. I can then use this to open in an Iframe or childBrowser in a mobile app.

All the alerts are my guesses at what the syntax should be from my web searches. The first answer is here Capturing .click for URLs.

function noopHandler(evt) {

//alert($(this).attr("href") + "/");
//alert(app.w('label').base().attr("href") + "/");
//alert(app.w('label').base()[0].attr("href") + "/");
//alert($(this).find("a").attr('href'));
//alert(app.OBJ2JSON(app.w('label').base()));
//alert(app.OBJ2JSON(app.w('label').base()[0]));
evt.stopPropagation();
evt.preventDefault();
}

function handler_application_onAppStarted(){

var labelToCheck = app.w('label').base()[0];


labelToCheck.addEventListener('click', noopHandler, false);

}

MrWarby

Community
  • 1
  • 1
user3193843
  • 295
  • 1
  • 3
  • 15
  • 1
    Since you've tagged jQuery: `$('yourelementname').click(function(e){ e.preventDefault(); var yourHREF = $(this).attr('href'); alert(yourHREF); });` - fiddle: http://jsfiddle.net/M9KtE/ – scrowler Jan 27 '14 at 19:42
  • Hi Scrowler, I added your code(using $('a') to the on app started event and it worked. So I added some links to label1 and these were blocked as well. What would I need to change to apply this only to my widget 'label'. When I replace 'a' with 'label' it does not work. I am presuming my widget called label is not referenced as this. How do I find out how to reference 'label. – user3193843 Jan 28 '14 at 00:30
  • @scrowler Hi just found the @ notification. Please see above if you have any idea. I have realised that capturing all links (this fires on a button press as well ) is not an issue as I can control what happens. But I would like to be able to action this just on one 'widget' for my own knowledge and future projects. – user3193843 Jan 30 '14 at 10:01

0 Answers0