如何使用window.open打开屏幕中心的页面? [英] How can I use window.open to Open a page in the center of screen?

查看:285
本文介绍了如何使用window.open打开屏幕中心的页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:


如何使用window.open打开屏幕中心的页面?


我知道showModalDialog()可以,但我必须在IE和NN中运行,所以我必须使用window.open打开一个新页面。


是否有任何帮助?

非常感谢。


***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!

Hi,everybody:

How can I use window.open to Open a page in the center of screen?

I know showModalDialog() can,but I have to run both in IE and NN, so I
have to use window.open to open a new page.

Is ther any help?
Thanks a lot.

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!

推荐答案



" Clare Hsiao" < CL ********* @ hotmail.com> schreef in bericht

news:40 ********************* @ news.frii.net ...

"Clare Hsiao" <cl*********@hotmail.com> schreef in bericht
news:40*********************@news.frii.net...

如何使用window.open打开屏幕中心的页面?

我知道showModalDialog()可以,但我必须在IE和NN中运行,所以我必须使用window.open打开一个新页面。

是否有任何帮助?
非常感谢。

***通过开发人员指南 http://www.developersdex.com 发送* **
不要只是参加USENET ......获得奖励!
Hi,everybody:

How can I use window.open to Open a page in the center of screen?

I know showModalDialog() can,but I have to run both in IE and NN, so I
have to use window.open to open a new page.

Is ther any help?
Thanks a lot.

*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!




1)找出屏幕的宽度和高度,

2)现在想要打开的窗口的高度和宽度计算新窗口的顶部和左边的




function centerWindow(){


win_height = 400;

win_width = 500;

win_top =(screen.availHeight -win_height)/ 2;

win_left =(screen.avail Width-win_width)/ 2;


url =''http://www.google.com'';

name ='''';

features =" width =" + win_width +",height =" + win_height +",top =" + win_top +",

left =" + win_left;

// alert(features);

return window.open(url,name,features);

在javascript中,



1) Find out the width and height of the screen,
2) Nowing the height and width of the window you want to open calculate the
top and the left for the new window:

function centerWindow(){

win_height=400;
win_width=500;
win_top=(screen.availHeight-win_height)/2;
win_left=(screen.availWidth-win_width)/2;

url=''http://www.google.com'';
name='''';
features="width="+win_width+", height="+win_height+", top="+win_top+",
left="+win_left;
//alert(features);
return window.open(url,name,features);
}


,字符串总是放在两个"

之间

url =" http://www.google.com"

if url =''http://www.google.com''

会发生一些错误。
in javascript,strings are always put between two ""
such
url="http://www.google.com"
if url=''http://www.google.com''
some error will happen.


Bluelava写道:
Bluelava wrote:
在javascript中,字符串总是放在两个"
之间
url =" http ://www.google.com"
如果url =''http://www.google.com''
会发生一些错误。
in javascript,strings are always put between two ""
such
url="http://www.google.com"
if url=''http://www.google.com''
some error will happen.




总公牛。


myString =''单引号中的一些文字'';

myOtherString ="我的另一个带双引号的字符串" ;;


myThirdString =''我的第三个字符串带有\'单引号\''引用它'' ;


唯一的要求是你逃避在里面和''里面''。

-

兰迪

机会有利于准备好的心灵

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



Total bull.

myString = ''Some text in single quotations'';
myOtherString = "My other string with double quotations";

myThirdString = ''My Third string with a \''single quoted\'' quote in it'';

The only requirement is that you escape " inside " and '' inside ''.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/


这篇关于如何使用window.open打开屏幕中心的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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