如何创建一个弹出窗口(好的一种)

时间:2022-11-20 10:38:09

I need to make a pop-up window for users to log-in to my website from other websites.

我需要为用户创建一个弹出窗口,以便从其他网站登录我的网站。

I need to use a pop-up window to show the user the address bar so that they know it is a secure login, and not a spoof. For example, if I used a floating iframe, websites could spoof my login window and record the user's login information.

我需要使用一个弹出窗口向用户显示地址栏,以便他们知道这是一个安全的登录,而不是欺骗。例如,如果我使用浮动iframe,网站可能会欺骗我的登录窗口并记录用户的登录信息。

Thanks

Additional details: My pop-up will come from javascript code from within an iframe in any domain. I know this sounds like I'm creating adverts.. but really I'm not. If it makes any difference, the iframe domain and the pop-up domain are the same.

其他详细信息:我的弹出窗口将来自任何域中iframe内的javascript代码。我知道这听起来像是在制作广告..但我真的不是。如果它有任何区别,iframe域和弹出域是相同的。

1 more detail, I'm looking to do the same thing "Facebook Connect" does... if you aren't logged into facebook, they allow you to login to facebook from any domain by showing a pop-up on that domain's site. For an example, go to any article at techcrunch.com and use Facebook Connect to comment. Make sure you're logged out of facebook and you'll see what I'm talking about.

另外1个细节,我希望做同样的事情“Facebook Connect”确实...如果你没有登录Facebook,它们允许你通过在该域名的网站上显示弹出窗口从任何域名登录Facebook 。例如,转到techcrunch.com上的任何文章并使用Facebook Connect进行评论。确保你已经退出Facebook,你会看到我在说什么。

5 个解决方案

#1


4  

Take a look at this site.

看看这个网站。

Some code copied from it:

从中复制的一些代码:

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');  
    if(!newindow){
        alert('We have detected that you are using popup blocking software...');}
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>

And you link to it with:

你链接到它:

<a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a> 

#2


1  

Sean example is good, but you can still detect if the pop up has been blocked in the following way:

肖恩的例子很好,但您仍然可以通过以下方式检测弹出窗口是否被阻止:

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if(!newwindow){
 alert('We have detected that you are using popup blocking software...');}

if (window.focus) {newwindow.focus()}
return false;
}

// -->
</script>

#3


0  

Pop up blockers do not come into effect if they are rendered on explicit user action like a link or a button click. Even if your browser is configured with pop ups blocked, Facebook connect window still renders. Thats because the connect button was clicked by the user. It doesnt matter even if the domain of the current site and the site in the pop up window differ.

弹出窗口阻止程序如果在显式用户操作(如链接或按钮单击)上呈现,则不会生效。即使您的浏览器配置了弹出窗口被阻止,Facebook连接窗口仍然呈现。那是因为用户点击了连接按钮。即使当前站点的域和弹出窗口中的站点不同,也无关紧要。

#4


0  

This is How to create a pop-up window..

这是如何创建弹出窗口..

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Open "myWindow"</button>
<button onclick="closeWin()">Close "myWindow"</button>

<script>
var myWindow;

function openWin() {
    myWindow = window.open("", "myWindow", "width=200,height=100");
    myWindow.document.write("<p>This is 'myWindow'</p>");
}

function closeWin() {
    myWindow.close();
}
</script>

</body>
</html>

#5


-1  

If your users are using IE, and your site is in the trusted sites, the popup blocker will be deactivated.

如果您的用户使用的是IE,并且您的站点位于受信任的站点中,则会禁用弹出窗口阻止程序。

Does that help?

这有帮助吗?

#1


4  

Take a look at this site.

看看这个网站。

Some code copied from it:

从中复制的一些代码:

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');  
    if(!newindow){
        alert('We have detected that you are using popup blocking software...');}
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>

And you link to it with:

你链接到它:

<a href="popupex.html" onclick="return popitup('popupex.html')">Link to popup</a> 

#2


1  

Sean example is good, but you can still detect if the pop up has been blocked in the following way:

肖恩的例子很好,但您仍然可以通过以下方式检测弹出窗口是否被阻止:

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if(!newwindow){
 alert('We have detected that you are using popup blocking software...');}

if (window.focus) {newwindow.focus()}
return false;
}

// -->
</script>

#3


0  

Pop up blockers do not come into effect if they are rendered on explicit user action like a link or a button click. Even if your browser is configured with pop ups blocked, Facebook connect window still renders. Thats because the connect button was clicked by the user. It doesnt matter even if the domain of the current site and the site in the pop up window differ.

弹出窗口阻止程序如果在显式用户操作(如链接或按钮单击)上呈现,则不会生效。即使您的浏览器配置了弹出窗口被阻止,Facebook连接窗口仍然呈现。那是因为用户点击了连接按钮。即使当前站点的域和弹出窗口中的站点不同,也无关紧要。

#4


0  

This is How to create a pop-up window..

这是如何创建弹出窗口..

<!DOCTYPE html>
<html>
<body>

<button onclick="openWin()">Open "myWindow"</button>
<button onclick="closeWin()">Close "myWindow"</button>

<script>
var myWindow;

function openWin() {
    myWindow = window.open("", "myWindow", "width=200,height=100");
    myWindow.document.write("<p>This is 'myWindow'</p>");
}

function closeWin() {
    myWindow.close();
}
</script>

</body>
</html>

#5


-1  

If your users are using IE, and your site is in the trusted sites, the popup blocker will be deactivated.

如果您的用户使用的是IE,并且您的站点位于受信任的站点中,则会禁用弹出窗口阻止程序。

Does that help?

这有帮助吗?