The Browser Object Model

The Browser Object Model

As you’ve learned and worked with ASP, you’ve come to depend on the server object model documentation a lot to answer many queries. When do we need the properties of the Server object? Where is that Cookies collection? Is it the Response object, the Request object, or both? The object model provided by ASP is how we interface with the server, and it’s of utmost importance.
As you might expect, on the client-side, the browser object model is just as important. All of the interactions between our code and the browser take place via the object model, and without a good knowledge of how it is set up, our code either won’t work as well as it could, or it won’t work at all!
For the rest of this chapter, we’ll be covering the different objects in the browser object model, explaining how they relate to each other, and showing you some more examples. We need to understand exactly why we have to say things like Document.frmTest.txtURL.Value.
An Overview of the Browser
In the ASP object model, there are five main objects: Server, Response, Request, Session, and Application. These top-level objects have properties, methods, and subordinate objects where appropriate. Although it’s set up a bit differently, the browser object model follows the same principle of providing access to the features of the browser. Instead of five separate objects, the browser has one top level object called Window. The rest of the browser’s objects are located beneath the Window object in a logical hierarchy of functionality.
The Window object represents the browser itself. It has a number of self-contained properties, like status (the current text of the status bar at the bottom of the browser) that reflect and provide access to the browser. Its methods perform operations that make sense for the browser window, like opening another window and navigating to a new page. And, last but not least, it fires events every time it finishes loading a page, or completes unloading a page in preparation for moving to a new URL or shutting down.
To script programmers, the Window object’s subordinate objects are just as interesting as its immediate properties, methods, and events.

  • The Document object: represents the document currently displayed

  • The Frames collection: represents the frames in the current window

  • The History object: represents the history list of the browser

  • The Location object: represents the current URL that the browser is displaying

  • The Navigator object: represents information about the browser itself, like the version number

Of these objects, the Document object is by far the most utilized by the average script developer. It provides access to objects in the page currently displayed in the browser with the Link, Anchor, and Form collections. If we think back to our previous series of Hello World examples, we’ll realize that we’ve been using the Forms collection of the Document object from the beginning of this chapter.
The rest of this section covers each of these elements in a bit more detail, focusing especially on the Window and Document objects.
Covering every last aspect of the scripting object model would occupy many chapters (and indeed does in many books about client-side scripting). In this chapter we’ll give an overview and cover the most important elements. For more information, please check out the Wrox Press book Instant VBScript, and the Scripting Object Model document available from Microsoft’s Web site at http://www.microsoft.com (search for scriptom).
Since the Window object is the root of many useful objects in the object model, we’ll start by looking at it first.

https://msdn.microsoft.com/en-us/library/ms952643.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值