انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Javascript Window Object in details- very important object

الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 3
أستاذ المادة حۡــسۜــنۨ ا̍ڷــڔهــٻۧــمۘــې       3/17/2012 9:03:06 PM
Window Object

The window object represents an open window in a browser. If a document contain frames (<frame> or <iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame. There is no public standard that applies to the Window object, but all major browsers support it.

Window Object Properties :

• closed Returns a Boolean value indicating whether a window has been closed or not
• document Returns the Document object for the window (See Document object)
• frames Returns an array of all the frames (including iframes) in the current window
• history Returns the History object for the window (See History object)
• length Returns the number of frames (including iframes) in a window
• location Returns the Location object for the window (See Location object)
• name Sets or returns the name of a window
• opener Returns a reference to the window that created the window
• parent Returns the parent window of the current window
• status Sets the text in the statusbar of a window

Window Object Methods

• alert() Displays an alert box with a message and an OK button
• blur() Removes focus from the current window
• clearInterval()Clears a timer set with setInterval()
• clearTimeout() Clears a timer set with setTimeout()
• close() Closes the current window
• confirm() Displays a dialog box with a message and an OK and a Cancel button
• focus()Sets focus to the current window
• moveTo() Moves a window to the specified position
• open() Opens a new browser window
• print() Prints the content of the current window
• prompt() Displays a dialog box that prompts the visitor for input
• scroll()
• scrollBy() Scrolls the content by the specified number of pixels
• scrollTo() Scrolls the content to the specified coordinates
• setInterval() Calls a function or evaluates an expression at specified intervals (in milliseconds)
• setTimeout() Calls a function or evaluates an expression after a specified number of milliseconds

Open Method with Window Object

Syntax : window.open(URL,name,specs,replace)
Arguments Description :

URL[Optional].
Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened
name[Optional].
Specifies the target attribute or the name of the window. The following values are supported:

• _blank - URL is loaded into a new window. This is default
• _parent - URL is loaded into the parent frame
• _self - URL replaces the current page
• _top - URL replaces any framesets that may be loaded
• name - The name of the window


specs[Optional]. A comma-separated list of items. The following values are supported:
channelmode=yes|no|1|0 Whether or not to display the window in theater mode. Default is no. IE only
directories=yes|no|1|0 Whether or not to add directory buttons. Default is yes. IE only
fullscreen=yes|no|1|0 Whether or not to display the browser in full-screen mode. Default is no. A window in full-screen mode must also be in theater mode. IE only
height=pixels The height of the window. Min. value is 100
left=pixels The left position of the window
location=yes|no|1|0 Whether or not to display the address field. Default is yes
menubar=yes|no|1|0 Whether or not to display the menu bar. Default is yes
resizable=yes|no|1|0 Whether or not the window is resizable. Default is yes
scrollbars=yes|no|1|0 Whether or not to display scroll bars. Default is yes
status=yes|no|1|0 Whether or not to add a status bar. Default is yes
titlebar=yes|no|1|0 Whether or not to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box. Default is yes
toolbar=yes|no|1|0 Whether or not to display the browser toolbar. Default is yes
top=pixels The top position of the window. IE only
width=pixels The width of the window. Min. value is 100

replace[Optional]
Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:

• true - URL replaces the current document in the history list
• false - URL creates a new entry in the history list



Example : 1
<script type="text/javascript">
myWindow=window.open( , , width=200,height=100 )
myWindow.document.write("<p>This is myWindow </p>")
myWindow.focus()
</script>

Example : 2
function open_win() {
window.open("http://www.w3schools.com") }
</script>
<input type="button" value="Open Window" onclick="open_win()" />


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .