问题描述
您好,
我正在尝试弹出一个弹出窗口以便在重新点击时保持焦点。
下面的脚本应该是产生这种确切的行为,
然而它不起作用,至少在firefox 1.0.7和moz 1.7.12
(linux kubuntu)。它确实与konqueror一起工作。
它似乎与windows上的firefox一起使用但不适用于IE(不完全是
肯定)。
< ; script type =" text / javascript">
var WindowObjectReference = null; //全局变量
函数openFFPromotionPopup()
{
if(WindowObjectReference == null || WindowObjectReference.closed)
/ *如果指向内存中窗口对象的指针不存在
或者如果这样的指针存在但是窗口关闭了* /
{
WindowObjectReference =
window.open(" http://www.spreadfirefox.com/" ;,
" ; PromoteFirefoxWindowName",
" resizable = yes,scrollbars = yes,status = yes");
/ *然后创建它。将创建新窗口,并且
将被带到任何其他窗口的顶部。 * /
}
else
{
WindowObjectReference.focus();
/ *否则窗口引用必须存在且窗口
未关闭;因此,我们可以使用focus()方法将其重新置于任何
其他
窗口之上。没有必要在窗口重新创建
或重新加载引用的资源。 * /
};
}
< / script>
(... )
< p>< a href =" http://www.spreadfirefox.com/"
target =" PromoteFirefoxWindowName"
onclick =" openFFPromotionPopup();返回false;
title ="此链接将创建一个新窗口或将重新使用
已经打开的一个>促进Firefox采用< / a> ;< / p>
奇怪的是......它是从
复制而来的 http://developer.mozilla.org/en/docs....open#Examples !
我必须提到我已经激活javscript并允许它控制
焦点与firefox甚至禁用bpopup阻止,但它没有帮助
帮助: (我在网上或在这个新闻组中找到的很多variante也没有。
我真的很无能,但我'我正赶上javascript,所以我希望
我错过了一个明显的观点。
所以如果有的话
Hello,
I''m trying to get a popup to keep focus when it is re-clicked.
The script below is supposed to produce this exact behaviour,
however it doesn''t work, at least on firefox 1.0.7 and moz 1.7.12
(linux kubuntu). It does work with konqueror.
It seems to work with firefox on windows but not with IE (not completly
sure though).
<script type="text/javascript">
var WindowObjectReference = null; // global variable
function openFFPromotionPopup()
{
if(WindowObjectReference == null || WindowObjectReference.closed)
/* if the pointer to the window object in memory does not exist
or if such pointer exists but the window was closed */
{
WindowObjectReference =
window.open("http://www.spreadfirefox.com/",
"PromoteFirefoxWindowName",
"resizable=yes,scrollbars=yes,status=yes");
/* then create it. The new window will be created and
will be brought on top of any other window. */
}
else
{
WindowObjectReference.focus();
/* else the window reference must exist and the window
is not closed; therefore, we can bring it back on top of any
other
window with the focus() method. There would be no need to
re-create
the window or to reload the referenced resource. */
};
}
</script>
(...)
<p><a href="http://www.spreadfirefox.com/"
target="PromoteFirefoxWindowName"
onclick="openFFPromotionPopup(); return false;"
title="This link will create a new window or will re-use
an already opened one">Promote Firefox adoption</a></p>
The weird thing is... it is copied from
http://developer.mozilla.org/en/docs....open#Examples !
I must mention that i''ve activated javscript and allowed it to control
focus with firefox and even disabled bpopup blocking, but it didn''t
helped :(, neither did the many variante i''ve found on the web or in
this newsgroup.
I''m really clueless, but i''m just catching up with javascript so i hope
i''ve missed an obvious point.
So if anyone
推荐答案
Don 't。
PointedEars
Don''t.
PointedEars
thx很多啊
thx a lot ah
我的第一次跟进可能不够启发;-)
你想要做的事情之所以是坏事:
< URL:http://www.faqs.org/faqs/x-faq/part7/section-42.html>
(这是关于X Window系统的编程,但我确定你无论如何都得到了
的想法。)
聚焦窗口肯定不能用于基于Gecko的
UAs,因为我们有偏好呃可以阻止你从窃取中掏出
焦点,默认情况下启用。太多了
过去曾经尝试过无能为力的剧本小孩。
请在下次提供引用材料的归属地:
< URL:http://jibbering.com/faq/faq_notes/pots1.html>
< URL:http://www.safalra.com/special/googlegroupsreply/ >
PointedEars
My first followup probably was not enlightening enough ;-)
The reason why what you are trying to do is a Bad Thing:
<URL:http://www.faqs.org/faqs/x-faq/part7/section-42.html>
(This is about programming for the X Window System, but I''m sure you get the
idea anyway.)
Focusing the window most certainly does not work with your Gecko-based
UAs because there are Preferences with which the user can prevent you
from "stealing" the focus, that are enabled by default. Too many
clueless script-kiddies have attempted this in the past.
Please provide attribution of quoted material next time:
<URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:http://www.safalra.com/special/googlegroupsreply/>
PointedEars
这篇关于弹出focus()行为与moz,firefox,即的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!