Posting form to a hidden iframe in Android browser

2019-05-29 03:09发布

问题:

I just noticed that one of the things that keep working in browsers on PC, does not work on an Android browser.

I want to POST a form to a hidden iframe. This is basically to initiate a file download after verifying user credentials.

<form method="post" action='/downloader.php' target="hiddenframe">
    ....
    ......
    ...
    <input type="submit" value="Download">
</form>

<iframe name="hiddenframe" style="display:none;"></iframe>

This doesn't work on Android browsers. I suppose I should be concerned of the iframe. What should I take care of or what alternatives I have to make this work?

Thank you for any insight.

回答1:

I don't know how Android handles frames, plus different Android roms use different browsers.

What I do know is that as of HTML5 frames are deprecated, therefore not a very good practise. If not anything you are going to have more and more compatibility issues with new browsers in the future.

Why don't you do the request on the same page? If the downloader.php has the proper headers the download process should start without breaking or changing the current page at all.



回答2:

check this notes about using iframe in Android:

dose apple and Android Browsers support Iframe??

I hope this helps you.