重复将焦点返回到同一弹出窗口 [英] Return focus to same pop-up window repeatedly

查看:72
本文介绍了重复将焦点返回到同一弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近才回到(尝试)做简单的JS,所以这是

可能是一个非常蹩脚的问题。


我有其中包含一系列图形的网页(窗口A)。


点击A中的图形会在A上打开一个小弹出窗口(窗口B)。


如果访问者点击B,它会关闭。


如果访问者点击A - 页面或新图形 - A来了

到最前面并隐藏B.


如果B保持打开(访客没有点击它)和访问者点击

A上的另一个图形,B的内容被新的

链接指向的内容所取代(或者如果点击相同的图形则相同)。


我可以完成以上所有事情。我无法弄清楚的是如何设置

将重点放在B上,以便在A中的图形上点击

之后它就会出现在最前面。我已经用各种各样的方式弄乱了焦点()

但是不能让B回到前台。我的尝试包括

在页面加载中添加焦点语句(下面的

示例中的graphic.html)。


这个是有用的:


函数secWin(url){

window.open(url," imagePopUp"," width = 270,height = 225 ,left = 50,top = 50");

}


使用如下


< a HREF ="的JavaScript的 的:secWin( '' graphic1.html '');">图片< / a>


我希望有人可以为我理顺这一点。谢谢。

解决方案

Richard Shewmaker在1/19/2006 12:52 AM说了以下内容:

我是我们最近才回到(尝试)做简单的JS,所以这可能是一个非常蹩脚的问题。

我有一个网页,里面有一系列图形(窗口A)点击A中的图形会在A上打开一个小弹出窗口(窗口B)。

如果访问者点击B,它会关闭。

如果访问者点击A - 页面或新图形 - A来到最前端并隐藏B.

如果B保持打开(访客确实如此)没有点击它)并且访问者点击了A上的另一个图形,B的内容被新的
链接指向的内容所取代(或者如果点击相同的图形则相同)。 />
我可以完成以上所有事情。我无法弄清楚的是如何将焦点重新设置在B上,以便它在A中的图形上单击
后出现在最前面。我已经弄乱了焦点()以各种方式
但不能让B回到前台。我的尝试包括在页面加载中添加焦点语句(下面的
示例中的graphic.html)。

这是有效的:

function secWin(url){
window.open(url," imagePopUp"," width = 270,height = 225,left = 50,top = 50");


var myWindowReference = window.open(...);

myWindowReference.focus();

}

使用如下

< a href =" javascript :secWin(''graphic1.html'');"> image< / a>



http:/ /jibbering.com/faq/#FAQ4_24


-

兰迪

comp。 lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /

答案:它会破坏对话的顺序

问题:为什么?

答案:Top-发布。

问题:Usenet上最烦人的事情是什么?


请引用你要回复的内容。


如果您想通过groups.google.com发布跟进,请不要使用

回复链接在文章的底部。点击显示选项在

文章的顶部,然后点击回复。在

文章标题的底部。


Randy Webb写道:

Richard Shewmaker说以下是1/19/2006 12:52 AM:

我最近才回到(尝试)做简单的JS,所以这可能是一个非常蹩脚的问题。

我有一个网页,里面有一系列图形(窗口A)。

点击A中的图形打开一个小弹出窗口(窗口B)在A.

如果访问者点击B,它就会关闭。

如果访问者点击A - 页面或新图形 - A 走到最前面并隐藏B.

如果B保持打开(访问者没有点击它)并且访问者点击了A上的另一个图形,则B的内容被替换为
新链接指向(或者如果点击相同的图形则相同)。

我可以完成上述所有操作。我无法弄清楚的是如何将焦点重新设置在B上,以便它在A中的图形上单击
后出现在最前面。我已经弄乱了焦点()以各种各样的方式,但不能让B回到前台。我的尝试包括在页面加载中添加焦点语句(下面的例子中的graphic.html)。

这是有效的:

function secWin(url){
window.open(url," imagePopUp"," width = 270,height = 225,left = 50,top = 50");



var myWindowReference = window.open(...);
myWindowReference.focus();

}

使用如下

< a href =" javascript :secWin(''graphic1.html'');"> image< / a>



http:/ /jibbering.com/faq/#FAQ4_24




嗨。谢谢。这是我做过的尝试之一(所以我觉得现在不是很傻)。我想,因为你在这里给我这个

它必须工作...所以我的第一个怀疑是我的浏览器。猜猜是什么?

这就是问题所在。


它在IE6上运行得很好,在Win32上运行的是Opera 8,但它在

Firefox 1.5!是时候让我在Mozillazine上添加一个注释。


Randy Webb写道:

Richard Shewmaker在1/19上说了以下内容2006 12:52 AM:

我最近才回到(尝试)做简单的JS,所以这可能是一个非常蹩脚的问题。
我有一个网页,里面有一系列图形(窗口A)。

点击A中的图形会在A上打开一个小弹出窗口(窗口B)。

如果访问者点击B,它就会关闭。

如果访问者点击A - 页面或新图形 - A
出现在最前面并隐藏B.

如果B保持打开状态(访问者没有点击它)并且访问者点击了A上的另一个图形,则B的内容将被替换为
新链接指向(如果点击相同的图形,则相同)。

我可以完成以上所有操作。我无法弄清楚的是如何将焦点重新设置在B上,以便它在A中的图形上单击
后出现在最前面。我已经弄乱了焦点()以各种各样的方式,但不能让B回到前台。我的尝试包括在页面加载中添加焦点语句(下面的例子中的graphic.html)。

这是有效的:

function secWin(url){
window.open(url," imagePopUp"," width = 270,height = 225,left = 50,top = 50");



var myWindowReference = window.open(...);
myWindowReference.focus();




Randy,如果窗口是新的,那里没有必要关注()它。只有当网址不同时才应该关注

调用。


OP需要的是这样一个例子(第三个,最后一个) :

http:/ /developer.mozilla.org/en/docs...Best_practices


此外,用户必须选中复选框允许脚本:提高或降低
windows to在Mozilla或Firefox中。与Opera 8+相同。

$ b $bGérard

-

删除等等给我发电子邮件


I''ve only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A comes
to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the new
link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can''t figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I''ve messed around with focus() in all sorts of ways
but can''t get B to come back to the foreground. My attempts include
adding a focus statement in the page loading (graphic.html in the
example below).

This is what works:

function secWin(url) {
window.open(url,"imagePopUp","width=270,height=225 ,left=50,top=50") ;
}

used as follows

<a href="javascript:secWin(''graphic1.html'');"> image </a>

I hope someone can straighten this out for me. Thanks.

解决方案

Richard Shewmaker said the following on 1/19/2006 12:52 AM:

I''ve only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A comes
to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the new
link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can''t figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I''ve messed around with focus() in all sorts of ways
but can''t get B to come back to the foreground. My attempts include
adding a focus statement in the page loading (graphic.html in the
example below).

This is what works:

function secWin(url) {
window.open(url,"imagePopUp","width=270,height=225 ,left=50,top=50") ;
var myWindowReference = window.open(...);
myWindowReference.focus();
}

used as follows

<a href="javascript:secWin(''graphic1.html'');"> image </a>



http://jibbering.com/faq/#FAQ4_24


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don''t use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.


Randy Webb wrote:

Richard Shewmaker said the following on 1/19/2006 12:52 AM:

I''ve only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A
comes to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the
new link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can''t figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I''ve messed around with focus() in all sorts of
ways but can''t get B to come back to the foreground. My attempts
include adding a focus statement in the page loading (graphic.html in
the example below).

This is what works:

function secWin(url) {
window.open(url,"imagePopUp","width=270,height=225 ,left=50,top=50") ;



var myWindowReference = window.open(...);
myWindowReference.focus();

}

used as follows

<a href="javascript:secWin(''graphic1.html'');"> image </a>



http://jibbering.com/faq/#FAQ4_24



Hi. Thank you. That was one of the attempts I made (so I don''t feel
quite so stupid now). I figured since you were giving it to me here that
it must work ... so my first suspect was my browser. And guess what?
That''s the problem.

It works just fine in IE6, Opera 8 on Win32, but it does not work in
Firefox 1.5! Time for me to add a note to that effect on Mozillazine.


Randy Webb wrote :

Richard Shewmaker said the following on 1/19/2006 12:52 AM:

I''ve only recently returned to (trying to) doing simple JS, so this is
probably a really lame question.

I have a Web page with a series of graphics in it (window A).

Clicking on a graphic in A opens a small pop-up window (window B) over A.

If the visitor clicks on B, it closes.

If the visitor clicks back on A -- the page or a new graphic -- A
comes to the forefront and hides B.

If B remains open (visitor does not click on it) and visitor clicks on
another graphic on A, the contents of B are replaced by whatever the
new link points to (or the same if the same graphic is clicked on).

I can make all the above happen. What I can''t figure out is how to set
the focus back on B, so that it comes to the forefront, after clicking
on a graphic in A. I''ve messed around with focus() in all sorts of
ways but can''t get B to come back to the foreground. My attempts
include adding a focus statement in the page loading (graphic.html in
the example below).

This is what works:

function secWin(url) {
window.open(url,"imagePopUp","width=270,height=225 ,left=50,top=50") ;



var myWindowReference = window.open(...);
myWindowReference.focus();



Randy, if the window is new, there is no need to focus() it. The focus
call should be done only if the url is different.

What the OP needed is an example like this one (3rd one, last one):

http://developer.mozilla.org/en/docs...Best_practices

Also, the user must check the checkbox "Allow scripts to:Raise or lower
windows to" in Mozilla or Firefox. Same thing with Opera 8+.

Gérard
--
remove blah to email me


这篇关于重复将焦点返回到同一弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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