window.open问题 [英] Problem with window.open

查看:102
本文介绍了window.open问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我试图在用户点击图片时弹出一个窗口。

问题是,当用户点击图像并且窗口弹出

时,OK,但下面的窗口也会进入图像。

期望的行为是,当弹出窗口被调用时,我希望

底层窗口保持不变。


当我在本地计算机上运行代码时,我没有遇到这个问题,但是当我在geocities上运行代码时,我确实拥有它。


网页代码很简单:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN">

< html>

< head>

< title>页面标题< / title>

< script language =" JavaScript" ; type =" text / javascript">

var tallParm =

''scrollbars = 1,toolbar = 0,location = 0,directories = 0,s tatus = 0,菜单栏= 0,可调整大小= 1,高度=''+(screen.hei ght

- 200)+'',width =''+(screen.width - 80);


函数pop_tall_image_win(ref){

window.open(ref," x",tallParm);

返回false;

}

< / script>

< / head>

< body>

< a href =" large.gif" onclick =" return

pop_tall_image_win(''large.gif'')">< img src =" small.gif" border =" 0">< / a>

< / body>

< / html>


我在地理位置页面上的位置是:
http: //www.geocities.com/sample_issue/index.htm


作为旁注,我仍然希望图像上的链接转到目标,

,以防用户决定使用右键打开新窗口。那是

为什么我有HREF参考。

Hi,

I am trying to pop-up a window when the user clicks on an image. The
problem is that when the user clicks on the image and the window pops
up OK, but the window underneath also proceeds to the image. The
desired behavior is that when the pop-up is invoked, I want the
underlying window to stay put.

I don''t have this problem when I run the code on my local computer but
I do have it when I run the code on geocities.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaScript" type="text/javascript">
var tallParm =
''scrollbars=1,toolbar=0,location=0,directories=0,s tatus=0,menubar=0,resizable=1,height=''+(screen.hei ght
- 200)+'',width='' + (screen.width - 80);

function pop_tall_image_win (ref) {
window.open(ref,"x",tallParm);
return false;
}
</script>
</head>
<body>
<a href="large.gif" onclick="return
pop_tall_image_win(''large.gif'')"><img src="small.gif" border="0"></a>
</body>
</html>

The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

As a side-note, I still want the link on the image to go to the target,
in case the user decides to use right-mouse open-new-window. That is
why I have the HREF reference.

推荐答案

le ********* @ gmail.com 写道:

<我试图在用户点击图像时弹出一个窗口。问题是,当用户点击图像并且窗口弹出
时,OK,但下面的窗口也会进入图像。
期望的行为是,当弹出窗口被调用时,我希望
底层窗口保持不变。

当我运行时,我没有这个问题我的本地计算机上的代码,但是当我在geocities上运行代码时,我确实拥有它。

网页代码很简单:

<!DOCTYPE HTML PUBLIC " - // W3C // DTD HTML 4.0 Transitional // EN">
< html>
< head>
< title>页面标题< / title>
< script language =" JavaScript" type =" text / javascript">
var tallParm =
''scrollbars = 1,toolbar = 0,location = 0,directories = 0,s tatus = 0,menubar = 0,resizable = 1,height =''+(screen.hei ght
- 200)+'',width =''+(screen.width - 80);

函数pop_tall_image_win(ref){
window.open(ref," x",tallParm);
返回false;
}
< / script>
< / head>
< body>
< a href =" large.gif" onclick =" return
pop_tall_image_win(''large.gif'')">< img src =" small.gif" border =" 0">< / a>
< / body>
< / html>

我在地理位置页面上的位置是:
http://www.geocities.com/sample_issue/index。 htm

作为旁注,我仍然希望图像上的链接转到目标,
以防用户决定使用右键打开 - 新-窗口。那就是为什么我有HREF参考。
Hi,

I am trying to pop-up a window when the user clicks on an image. The
problem is that when the user clicks on the image and the window pops
up OK, but the window underneath also proceeds to the image. The
desired behavior is that when the pop-up is invoked, I want the
underlying window to stay put.

I don''t have this problem when I run the code on my local computer but
I do have it when I run the code on geocities.

The webpage code is simple:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
<script language="JavaScript" type="text/javascript">
var tallParm =
''scrollbars=1,toolbar=0,location=0,directories=0,s tatus=0,menubar=0,resizable=1,height=''+(screen.hei ght
- 200)+'',width='' + (screen.width - 80);

function pop_tall_image_win (ref) {
window.open(ref,"x",tallParm);
return false;
}
</script>
</head>
<body>
<a href="large.gif" onclick="return
pop_tall_image_win(''large.gif'')"><img src="small.gif" border="0"></a>
</body>
</html>

The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm

As a side-note, I still want the link on the image to go to the target,
in case the user decides to use right-mouse open-new-window. That is
why I have the HREF reference.




尝试

< a href =" large.gif"的onclick = QUOT; pop_tall_image_win( large.gif);返回

false;">< img src =" small.gif" border =" 0">< / a>


- JS
http://www.endeavorpub.com



try
<a href="large.gif" onclick="pop_tall_image_win(''large.gif''); return
false;"><img src="small.gif" border="0"></a>

- JS
http://www.endeavorpub.com


le ********* @ gmail.com 写道:
le*********@gmail.com wrote:
我试图弹出 - 当用户点击图像时向上窗口。
< snip> < a href =" large.gif" onclick =" return


假设这个回车不在原始代码中(如果

,所描述的症状仍然不明显然后可以调用函数

)这段代码应该工作。

pop_tall_image_win(''large.gif'')">< img SRC =" small.gif"
^^^^^^^^^^


而不是将图像文件作为字符串文字传递给函数

使用 - 这个.href - 因为它将传递来自A元素的HREF和

,除非图像URL需要更改,否则你必须更新两个(b)消除一些潜在的错误在这个过程中。

border =" 0">< / a>
< snip>我在地理位置页面上的位置是:
http:/ /www.geocities.com/sample_issue/index.htm
I am trying to pop-up a window when the user clicks on an image. <snip> <a href="large.gif" onclick="return
Assuming that this carriage return is not in the original code (and if
it is the symptoms described still would not be evident as the function
would then ver be called) this code should ''work''.
pop_tall_image_win(''large.gif'')"><img src="small.gif" ^^^^^^^^^^

Rather than pass the image file to the function as a string literal
use - this.href - as that will pass on the HREF from the A element and
save you having to update both if the image URL needs changing
(eliminating some potential for making mistakes in the process).
border="0"></a> <snip> The place where I have the page on geocities is:
http://www.geocities.com/sample_issue/index.htm



< snip>


此网址的页面确实如此在Opera 8或IE 6上没有出现描述的症状(_not_

离开带链接的页面)


Richard。


<snip>

The page at this URL does not exhibit the symptoms described (does _not_
navigate away from the page with the link) on Opera 8 or IE 6.

Richard.




jshanman写道:

jshanman wrote:
尝试
< a href =" large.gif"的onclick = QUOT; pop_tall_image_win( large.gif);返回
false;">< img src =" small.gif" border =" 0">< / a>

- JS
http://www.endeavorpub.com



- >我只是尝试了这个想法(标记原始的1.和这个

的想法2.)并且两者的行为方式相同 - 再次不在本地,但是当我

在地理位置上运行它(公共互联网?)


--> I just gave that idea a try (labelling the original "1." and this
idea "2.") and both behave the same way -- again not locally but when I
run it on geocities (public Internet?)


这篇关于window.open问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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