I have an HTML 5 app that runs on mobile devices including the iPad. I want to create a link to a non-HTML file, and have the proper application open to handle the file. The files are .acsm files, to be opened in Bluefire.
If I create the link as a simple <a href="url">
tag, it works.
If instead I use Javascript to set the window.location
, it doesn't work. The iPad pops an alert that says, "Download failed: This file cannot be downloaded".
I've experimented with other file types, and haven't found anything conclusive. What's the difference between the simple link and the Javascript technique? Can I make the Javascript code do the same thing as the link?
In case the specific Javascript details matter, I do it like this with jQuery:
$('.native-launch').live('click', function (evobj) {
var there = $(evobj.target).attr('href');
window.location.href = there;
return false;
});
and the HTML looks like:
<span class="catalog-list-button native-launch" href="url">Read in another app</span>
(Note that this is a span with an href, I can change the HTML if that would help.)
Best Answer
Try
window.open
, passing in "_self" as the target window name.Using "_self" is the critical part here, otherwise the popup blocker would intercept it. I'd test this, but I don't have a link to an acsm file.
Edit: Two more ideas:
Add a form to your page with a method of "GET" and an action of your acsm file. Exclude form fields unless they map appropriately to your URL.
Then just submit your form with
form.submit()
:And the other idea: Create a page on your server that does a server-side redirect to your acsm file. Then just use the usual
location.href = url
to that server page.