简体   繁体   中英

Prevent standalone iOS web app from reloading after loading video

I have an AJAX based web app for iPhone. This app is mainly for watching videos. The user navigates some menus and then gets to a list of videos. On the video list, I have some code like this:

<a href="javascript:window.location='video.mp4'>Video Link</a>

On an iPhone, in Mobile Safari, this link opens the video and, after the video is over or the user clicks on OK, the video closes and the video list remains as it was before launching the video. This is the desired behavior.

When the app is used as a standalone app (add to home screen), after the video is closed the page is reloaded breaking the previous navigation.

Is there a way to prevent this from happening?

can you show some objective-c code. I think you have to use UIWebView delagate methods -

(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

and return NO if it is loading for the second time. Also check if you are loading videos list in viewWillAppear . If yes then use video listing viewDidLoad .

Try this:

<a href="javascript:window.location='video.mp4';return false;">Video Link</a>

or alternatively:

<a href="javascript:document.location='video.mp4';return false;">Video Link</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM