Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > javascript the attributes of the window.open
【标  题】:javascript the attributes of the window.open
【关键字】:javascript,the,attributes,of,the,window.open
【来  源】:http://blog.chinaunix.net/article.php?articleId=38271&blogId=6889

javascript the attributes of the window.open

Your Ad Here hehe,来看看这个吧。如果想用 javascript 打开一个特别的窗口,不知道这个可不成呦!

Using Inline JavaScript

Now let's add some JavaScript...

This link will open in a new window created by HTML and JavaScript.

Here the code is a bit more complicated...

<span class="popup" onClick=javascript:window.open("testwindow1.htm", code continues on next line
"blank","toolbar=no,width=250,height=250")>new window</span>

Although the text "new window" seems to be a hyperlink it isn't. It just looks and behaves like one. The text is enclosed not by the usual <a> tags but by <span> tags. These and the similar <div> tags are used to mark areas of the page that aren't unique in any other way, in this case a few words inside a paragraph, so that they can have attributes applied to them. In this case some formatting to color the text blue and make the mouse cursor display a hand when it is over the text (Find out how to do this!).

I wanted it to look like a hyperlink because it was going to behave like a hyperlink. I couldn't actually use a hyperlink because of what was going to happen next...

Atttached to the text is an onClick event that triggers one of the standard JavaScript functions, window.open. This function can have three parameters applied to it, and these control exactly what happens when the new window opens:

window.open("URL","name","attributes")

This is where you get to be creative with your windows. Here's what the various bits mean...

"URL": This is the address of the page that you want to open in the new window.

"name": This is a name of your choice. The purpose of providing a name is that you can then refer to it elsewhere. You might want a subsequent hyperlink to open in the same window you just created, replacing the earlier page. Your user doesn't have to shut down each window when they have finished with it. They just switch back when its contents change. You can leave out the name if you like, just type empty quotes: ""

"attributes": These are a set of instructions that tell the browser how to display the window. In the above example I have used toolbar=no which, when used alone tells the browser to open a basic window without toolbars, scroll bars, status bars etc. I have also specified an exact size by including width=250 and height=250, the numbers referring to pixels.

Here is a list of the more commonly used window attributes:

menubarSpecifies whether or not to display a menu bar at the top of the window. 

Value = yes or no, 1 or 0.

toolbarSpecifies whether or not to display the main toolbar (with the back, forward, stop etc. buttons). 

Value = yes or no, 1 or 0.

locationSpecifies whether or not to display the location bar (the Address Bar in Internet Explorer) - where URLs are typed and displayed.

Value = yes or no, 1 or 0.

directoriesSpecifies whether or not to display any additional toolbar (e.g the Links Bar in Internet Explorer).

Value = yes or no, 1 or 0.

statusSpecifies whether or not to display the status bar at the foot of the window.

Value = yes or no, 1 or 0.

scrollbarsSpecifies whether or not to display the horizontal and vertical scrollbars that normally appear when the page content is larger than the screen.

Value = yes or no, 1 or 0.

heightSpecifies the height of the window in pixels.

Value = number

widthSpecifies the width of the window in pixels.

Value = number

leftSpecifies the distance in pixels of the new window from the left edge of the screen. (This applies to Internet Explorer. For Netscape Navigator use screenX).

Value = number

topSpecifies the distance in pixels of the new window from the top edge of the screen. (This applies to Internet Explorer. For Netscape Navigator use screenY).

Value = number

resizableWhen enabled, allows the user to manually resize the window by dragging its edges or corners.

Value = yes or no, 1 or 0.

fullscreenWhen enabled causes the window to open in full-screen mode (Internet Explorer only.)

Value = yes or no, 1 or 0.

You will find that when, for example, you specify toolbar=no that other objects (location, menubar, scrollbars etc.) get switched off too. If you want to see any of them in your new window you will have to ask for them specifically.

播放流、字节数组、TTS声音转字节数组的类:【上一篇】
用java script控制打印机,设置页长:【下一篇】
【相关文章】
  • javascript Set the Window Position
  • encapsulate the concept that varies
  • window.open()的所有参数列表 (转载)
  • 在qt中实现offscreen rendering
  • Join together
  • Displays the menu path for a transaction
  • 学习Design Patterns(GoF)的步骤
  • Design Patterns (GoF) Opening Questions
  • 读书笔记之<<Learning the bash shell>> 之一
  • 读书笔记之<<Learning the bash shell>> 之三
  • 【随机文章】
  • JSP入门教程(1)
  • 微软最新安全漏洞大揭秘
  • 8.7.9 Destructors
  • 招商银行网上银行控件的安全隐患
  • ADO三大对象的属性、方法、事件及常数(一)
  • xml文档
  • 实施病毒营销的基本方式
  • 负载均衡
  • 液晶显示接口
  • 谁来关怀程序员? ZT
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.