window.open(...)不起作用 [英] window.open(...) does not work

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

问题描述

在html页面内(在JSP页面中更精确)我定义了一个按钮。

当用户单击此按钮时,第二个浏览器窗口会弹出并加载传递的

网址。我编码了


< img src =" mybutton.gif" onclick =''window.open(" http://mydomain.com"," Mytitle);''>


但是当我点击按钮时(在Win2000下) + IE5.5)没有弹出窗口。


为什么?


还有其他方法可以获得新的浏览器窗口吗?

Wladi

Inside a html page (more precicesly inside a JSP page) I defined a button.
When the user clicks this button a second browser window should pop up und load the passed
URL. I coded

<img src="mybutton.gif" onclick=''window.open("http://mydomain.com", "Mytitle);''>

However when I click on the button (under Win2000 + IE5.5) no window pops up.

Why?

Are there other ways to get a new browser window?

Wladi

推荐答案

Spake Wladimir Borsov给你:
Spake Wladimir Borsov unto thee:
还有其他方法可以获得新的浏览器窗口吗?
Are there other ways to get a new browser window?




我这样做的方式,如果我真的必须这样做,就是使用类似的链接:


< a href =" page.html"

onclick =" window.open('page.html'','' '','''width = 400,hei ght = 400'');返回

false;">链接文字< / a>


这样你就会得到一个新窗口,无论你建议的是什么尺寸

用户代理支持它,但如果没有,页面仍会打开。当然,

有数以百万计的原因,为什么一个人不应该使用新的窗户,但是我不想进入他们。


-

Dylan Parry
http: //webpageworkshop.co.uk - 免费网络教程和参考资料



The way I do it, if I really have to do it, is to use a link like:

<a href="page.html"
onclick="window.open(''page.html'','''',''width=400,hei ght=400''); return
false;">link text</a>

That way you get a new window of whatever size you suggest if the
user agent supports it, but the page still opens if it doesn''t. Of course,
there are millions of reasons why one shouldn''t use new windows, but I am
not going to go into them.

--
Dylan Parry
http://webpageworkshop.co.uk - FREE Web tutorials and references


Dylan Parry写道:
Dylan Parry wrote:
Spake Wladimir Borsov告诉你:

Spake Wladimir Borsov unto thee:

还有其他方法可以获得新的浏览器窗口吗?
Are there other ways to get a new browser window?



我的方式,如果我真的必须这样做,就是使用如下链接:

< a href =" page.html"
onclick =" window.open(''page.html '','''',''width = 400,hei ght = 400'');返回
false;">链接文字< / a>


The way I do it, if I really have to do it, is to use a link like:

<a href="page.html"
onclick="window.open(''page.html'','''',''width=400,hei ght=400''); return
false;">link text</a>




onclick =" window.open(this.href,this.target,''.....''); return false">

链接文字< / a>


每当我做这样的事情时,我通常会使用一个函数并传递

参数:


< a href =" somewhere.html" target =" _someWindow"

onclick =" myFunction(this.href,this.target); return false"> blah blah

< / a>


让维护更轻松。


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq


Wladimir Borsov写道:
Wladimir Borsov wrote:
< img src =" mybutton.gif" onclick =''window.open(" http://mydomain.com"," Mytitle);''>
<img src="mybutton.gif" onclick=''window.open("http://mydomain.com", "Mytitle);''>




你错过了引号。有更好的方法可以做你正在做的事情

虽然:


< a href =" http://example.net/" ; target =" Mytitle"

onclick =" window.open(this.href,this.target); return false;">

< img src =" mybutton.gif" alt ="转到example.net">< / a>


虽然弹出窗口当然是邪恶的。


-

Toby A Inkster BSc(荣誉)ARCS

联系我〜 http://tobyinkster.co.uk/contact



You''re missing a quote mark. There are better ways to do what you''re doing
though:

<a href="http://example.net/" target="Mytitle"
onclick="window.open(this.href,this.target); return false;">
<img src="mybutton.gif" alt="Go to example.net"></a>

Though popups are, of course, evil.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


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

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