根据if / if else语句显示popover的简单方法是什么? [英] What's an easy way to show a popover based on if / if else statements?

查看:153
本文介绍了根据if / if else语句显示popover的简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新的程序员,所以请光着我。我正在使用我的网站上的javascript在下面的链接。它确定用户1.是否已经允许我们的Facebook应用程序登录,2.没有允许我们的应用程序,但是已经登录到Facebook,或3.没有登录到Facebook。



我想要一个弹出窗口显示我的一些网站的内容(可能是600像素×400像素或某些东西),所以它作为一个内容拦截器,并告诉他们他们需要登录。弹出窗口在他们允许申请之后,他们会离开。



我的问题是这样的。如何在else if和if语句中编写弹出窗口?我可以做简单的事情,如document.write(如我的代码所示),但是如何在我的内容上显示一个弹出窗口?有没有办法可以从这些语句中轻松引用其他html和javascript?我甚至尝试使用一层,而不是将其分层在我的内容上,它将该图层显示为一个新页面,而不显示页面的内容。



我的目标是要一个弹出窗口显示内容刚好足以让用户看到背后确实有内容,所以他们更容易相信允许应用程序,所以他们可以看到这一切。


$ b $希望我已经清楚地解释了自己。如果有人能帮助我,我真的很感激!谢谢!!



Dan



http://pastebin.com/J882yh5F

解决方案

你可以轻松地做到这一点CSS。在 body 级别创建一个div,并设置为 position:absolute ,width和height为100%,另一个inner div 作为您自己的维度的警报消息。然后,您可以使用简单的显示:none 显示或隐藏自定义消息,显示:block p>

演示: http:/ /codepen.io/elclanrs/full/rGoha


I'm a new programmer so please bare with me. I'm using the javascript on my site seen on the link below. It determines if the user 1. has already allowed our Facebook app and is logged in, 2. hasn't allowed our application but is logged in to Facebook, or 3. isn't logged in to Facebook.

I want a popup to show up over some of my site's content (maybe 600px by 400px or something) so it acts as a content blocker of sorts and tells them they need to log in. The popup would then go away after they've allowed the application.

My problem is this. How do I code the popup inside the else if and if statements? I can do simple things like document.write (as seen in my code), but how do I show a popup over my content? Is there a way I can easily reference other html and javascript from within these statements? I even tried using a layer but instead of layering it over my content, it shows the layer as a new page without showing the page's content.

My goal here is to have a popup show up over the content just enough so the user can see that there is indeed content behind it so they're more easily convinced to allow the app so they can see it all.

Hope I've explained myself clearly. If anyone can help me, I'd really appreciate it! Thanks!!

Dan

http://pastebin.com/J882yh5F

解决方案

You can do this easily with just CSS. Create a div at body level, and set to position: absolute and width and height 100% and another inner div as the alert message with your own dimensions. Then you can show or hide the custom message with a simple display: none or display: block from JavaScript.

Demo: http://codepen.io/elclanrs/full/rGoha

这篇关于根据if / if else语句显示popover的简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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