从 html5
我正在 UIWebView 浏览器中运行的 Web 应用程序中自动播放 html5。我希望用户能够触摸屏幕并重定向到新页面。由于视频是自动播放的,我可以完全省略控件(并且该部分一切正常)。这个重定向可能吗?
到目前为止,我已经尝试过:
在视频标签周围添加链接 <视频类型='video/mp4' id="myVideo" width="800" height="568" src="video1 .ipad.mp4" autoplay>
将 onClick 事件添加到视频标签本身 <视频类型='video/mp4' id="myVideo" width="800" height="568" src="video1.ipad.mp4" onClick="document.location.href='http:// /www.example.com';" autoplay>
使用 onClick 事件在视频周围添加一个 div(然后当这不起作用时,增加 div 的 z-index 以确保它位于视频顶部)
任何想法将不胜感激......
I am autoplaying an html5 in a web app running in a UIWebView browser. I would like for the user to be able to touch the screen and be redirected to a new page. Since the video is autoplayed, I am able to omit the controls altogether (and that part is all working just fine). Is this redirection possible?
So far I have tried:
adding a link around the video tags<a href="http://www.example.com"><video type='video/mp4' id="myVideo" width="800" height="568" src="video1.ipad.mp4" autoplay></video></a>
adding an onClick event to the video tag itself<video type='video/mp4' id="myVideo" width="800" height="568" src="video1.ipad.mp4" onClick="document.location.href='http://www.example.com';" autoplay></video>
adding a div around the video with an onClick event (and then when that didn't work, increasing the div's z-index to make sure it was on top of the video)<div onclick="location.href='http://www.example.com';" style="cursor:pointer; z-index:10;"><video type='video/mp4' id="myVideo" width="800" height="568" src="video1.ipad.mp4" autoplay></video></div>
any ideas would be much appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我今天在做另一个项目时碰巧发现了一些有用的东西!我想我会将其发布在这里,以防其他人需要此功能。
基本上,我创建了一个围绕透明 div 的链接,该 div 是屏幕的完整尺寸,并通过 z-index 位于其他所有内容之上。
I happened to find something that worked today while working on another project! I thought I would post it here in case anyone else needs this functionality.
Basically, I created a link surrounding a transparent div that is the full size of the screen and sits on top of everything else via z-index.
如果您确实使用了正确的变量,那么使用第二种方法(onclick)应该可以工作:)
注意窗口,而不是文档。
(免责声明:没有在 iPad 上测试此功能,但在 Chrome 中可以使用)
Using your second approach (onclick) should work if you actually used the correct variable :)
Note window, not document.
(disclaimer: didn't test this on iPad but worked in Chrome)