如何使用浏览器的后退按钮关闭引导模式,而不是返回页面? [英] how to close a bootstrap modal with the browser back button instead of going back a page?`

查看:75
本文介绍了如何使用浏览器的后退按钮关闭引导模式,而不是返回页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现此问题与智能手机有关,并且可能与台式机有关.我们已经修改"了引导模式以进行响应,但是当在智能手机上以全屏显示时,用户会认为该模式是页面,然后单击以关闭"它.我们已经在右上方的X中添加了,但是还希望使用后退按钮来关闭模式.有人有什么想法吗?

谢谢

解决方案

最简单的方法是通过使用一些边距或使其跨度为offset1来使用户感觉其弹出窗口或模型不是新页面. >

另一种方法是描述这里

最好的方法是

<SCRIPT type="text/javascript">
   window.history.forward();
   function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"onpageshow="if (event.persisted) noBack();" onunload="">

此处

要从iFrame控制后退按钮,请尝试这样做可能有帮助(未测试)

<SCRIPT type="text/javascript">
   window.parent.history.forward();
   function noBack() { window.parent.forward(); }
</SCRIPT>
</HEAD>

I have found this an issue with smartphones and it can relate to desktops. We have 'modded' our bootstrap modal to be responsive, however when displayed on a smartphone it is in full screen, the user assumes the modal is a page and clicks back to 'close' it. We have included the in the top right X but would also like the back button to close the modal. Anyone have any ideas?

Thanks

解决方案

Easiest way is to make user feel that its pop-up or model not a new page, by using some margins or making it span10 offset1 kind of.

Another way around is Open and Close method which is described here

And the best method is

<SCRIPT type="text/javascript">
   window.history.forward();
   function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"onpageshow="if (event.persisted) noBack();" onunload="">

Described here

for controlling back button from iFrame, try this may help (not tested)

<SCRIPT type="text/javascript">
   window.parent.history.forward();
   function noBack() { window.parent.forward(); }
</SCRIPT>
</HEAD>

这篇关于如何使用浏览器的后退按钮关闭引导模式,而不是返回页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆