1

I'm trying to download an apk file from my webapp using a tablet.

<a href="#" data-role="button" id="loginButton" class="pulsantino">Login</a>

$("#pulsanteLogin").live("click",function(){
     alert("1");
     window.location.href = 'http://xx.yy.zz.www:1234/staticResources/Myapp_version.apk';
     alert("2");
}

I know for sure that the url is correct (launching it from the browser will correctly start file download), but when i click on the button i get no error and no file download. I get both the alerts for '1' and '2'.

I've tried also with

location.href = 'url';

and

window.location = 'url';

Ideas?

1
  • obviously 'url' is the url and not the string 'url' Commented Feb 5, 2013 at 19:53

2 Answers 2

1

Maybe this is too obvious, but why dont you just use a regular link like this directly:

<a href="http://xx.yy.zz.www:1234/staticResources/Myapp_version.apk" data-role="button" id="loginButton" class="pulsantino">Login</a>

Are you executing more code which requires the dynamic change of this link's href attribute?

Sign up to request clarification or add additional context in comments.

3 Comments

What might that logic be? Is that related to this very issue? If it is, you should post that as well and I'll be able to form a better answer.
i don't think the logic is related to the issue, it's just a check to the Android version
In that case, my answer would be a solution to your 'problem'; you don't need javascript to handle this click event.
0

Are you using a newer version of jQuery than 1.7? .live() got deprecated, and .on() is now the way to go. http://api.jquery.com/on/

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live(). Source: http://api.jquery.com/live/

3 Comments

Thanks for the suggestion, but as I said I get both alerts so the problem is not the click event
Also, couldn't you just do $("#pulsanteLogin").click(function(){ window.location.href = 'http://xx.yy.zz.www:1234/staticResources/Myapp_version.apk'; });
tried, still not working, don't get any error but file isn't downloading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.