WebFrame类参考

WebFrame类参考

继承
符合
框架
/系统/资源库/框架/  WebKit.framework
可用性
在Mac OS X v10.2时可使用Safari 1.0和更高版本。
可用在Mac OS X v10.2.7和更高版本。
同伴指导
申报的
WebFrame.h  
相关的示例代码

  WebFrame 对象封 数据 装在WebFrameView 对象 中显示 WebView 中每个框架 有一个WebFrame 对象。   一个完整的网页在主框架中层次WebFrame 对象表示

      每个WebFrame 也有WebDataSource 对象,管理加载框架内容。 使用loadRequest: 方法来启动一个异步的客户端请求,它创建一个临时的数据源。 收到 任何数据后 临时数据源转换成固定数据源。

当涉及 WebFrame时, 有一些特殊的,预定义的,框架的名称可以使用  一些预定义的名字框架是:为“_self”,“_ current ”,“_parent的和 “_top” 。看findFrameNamed:   框架名称也可以指定为HTML源代码,或根据用户要求设置。

      但是,组的名称是一个任意的标识符用于组织相关的框架。   例如,一个框架中运行的JavaScript可以访问同一组中的任何其他框架。   这取决于应用程序如何选择相关的框架范围。

任务

初始化框架

加载内容

获取数据源

获取相关框架和视图

寻找框架

获取DOM对象

  • – DOMDocument
  • – frameElement
  • – globalContext
  • – windowObject
  • Instance Methods

    childFrames

    Returns the frames of the web frame’s immediate children.

    - (NSArray   *)childFrames

    Return Value

    The web frame’s immediate children. Each child web frame is an instance of  WebFrame   and corresponds to an HTML frameset or  iframe   element.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    dataSource

    Returns the committed data source.

    - (WebDataSource   *)dataSource

    Return Value

    The committed data source, or  nil   if the provisional data source is not done loading.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    DOMDocument

    Returns the web frame’s DOM document.

    - (DOMDocument  *)DOMDocument

    Return Value

    The web frame’s DOM document.

    Discussion

    Returns  nil   if the receiver doesn’t have a DOM document; for example, if it’s a standalone image.

    Availability
    • Available in Mac OS X v10.3.9 and later.
    Declared In
    WebFrame.h

    findFrameNamed:

    Returns a web frame that matches the given name.

    - (WebFrame *)findFrameNamed:(NSString   *)name

    Parameters
    name

    The name of a frame.

    Return Value

    For predefined names, returns the receiver if name is “_self” or “_current”, returns the receiver’s parent frame if name is “_parent”, and returns the main frame if name is “_top”. Also returns the receiver if it is the main frame and name is either “_parent” or “_top.” For other names, this method returns the first frame that matches  name . Returns  nil   if no match is found.

    Discussion

    This method searches the receiver and its descendents first, then the receiver’s parent and its children moving up the hierarchy until a match is found. If no match is found in the receivers hierarchy, this method will search for a matching frame in other main frame hierarchies.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    frameElement

    Returns the web view’s DOM frame element.

    - (DOMHTMLElement  *)frameElement

    Return Value

    The web view’s DOM frame element. Returns  nil   if the receiver is the main frame.

    Discussion

    The returned object may be an instance of either  DOMHTMLFrameElement ,  DOMHTMLIFrameElement   or  DOMHTMLObjectElement .

    Availability
    • Available in Mac OS X v10.3.9 and later.
    Declared In
    WebFrame.h

    frameView

    Returns the web frame’s view object.

    - (WebFrameView   *)frameView

    Return Value

    The web frame’s view object.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    globalContext

    Returns the global JavaScript execution context for bridging between the WebKit and JavaScriptCore C API.

    - (JSGlobalContextRef)globalContext

    Return Value

    The global JavaScript execution context.

    Availability
    • Available in Mac OS X v10.4.11 and later.
    Declared In
    WebFrame.h

    initWithName:webFrameView:webView:

    Initializes the receiver with a frame name, web frame view, and controlling web view.

    - (id)initWithName:(NSString   *)frameName   webFrameView:(WebFrameView   *)frameView   webView:(WebView   *)webView

    Parameters
    frameName

    The frame name. Typically a custom name or  nil   (if none is specified). It would be inappropriate to use one of the predefined frame names described infindFrameNamed:   as they have special meanings.

    view

    The view that displays this web frame—the view associated with the receiver.

    webView

    The parent view that manages the main frame and its children.

    Return Value

    An initialized web frame.

    Discussion

    Normally, you do not invoke this method directly.  WebView   objects automatically create the main frame and subsequent children when new content is loaded. Send aloadRequest:   message to the main frame of a  WebView   to load web content.

    This method is the designated initializer for the  WebFrame   class.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    loadAlternateHTMLString:baseURL:forUnreachableURL:

    Loads alternate content for a frame whose URL is unreachable.

    - (void)loadAlternateHTMLString:(NSString   *)string   baseURL:(NSURL   *)URL   forUnreachableURL:(NSURL   *)unreachableURL

    Parameters
    string

    The string to use as the main page for the document.

    URL

    A file that is used to resolve relative URLs within the document.

    unreachableURL

    The URL for the alternate page content.

    Discussion

    Use this method to display page-level loading errors in a web view. Typically, a  WebFrameLoadDelegate   or  WebPolicyDelegate   object invokes this method from these methods:  webView:didFailProvisionalLoadWithError:forFrame:   (WebFrameLoadDelegate ),webView:decidePolicyForMIMEType:request:frame:decisionListener:   (WebPolicyDelegate ), orwebView:unableToImplementPolicyWithError:frame:   (WebPolicyDelegate ). If invoked from one of these methods, the back-forward list is maintained.

    Availability
    • Available in Mac OS X v10.3.9 and later.
    Declared In
    WebFrame.h

    loadArchive:

    Loads an archive into the web frame.

    - (void)loadArchive:(WebArchive   *)archive

    Parameters
    archive

    The archive to load.

    Availability
    • Available in Mac OS X v10.3.9 and later.
    Declared In
    WebFrame.h

    loadData:MIMEType:textEncodingName:baseURL:

    Sets the main page contents, MIME type, content encoding, and base URL.

    - (void)loadData:(NSData   *)data   MIMEType:(NSString   *)MIMEType   textEncodingName:(NSString   *)encodingName   baseURL:(NSURL   *)URL

    Parameters
    data

    The data to use for the main page of the document.

    MIMEType

    The MIME type of the data.

    encodingName

    The IANA encoding name (for example, “utf-8” or “utf-16”).

    URL

    A file that is used to resolve relative URLs within the document.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    loadHTMLString:baseURL:

    Sets the main page contents and base URL.

    - (void)loadHTMLString:(NSString   *)string   baseURL:(NSURL   *)URL

    Parameters
    string

    The string to use as the main page for the document.

    Since the string is treated as a webpage with UTF-8 encoding, the default encoding for any script elements referenced by the HTML is also UTF-8. To avoid this, include a character set attribute on the script element.

    URL

    A file that is used to resolve relative URLs within the document.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Related Sample Code
    Declared In
    WebFrame.h

    loadRequest:

    Connects to a given URL by initiating an asynchronous client request.

    - (void)loadRequest:(NSURLRequest   *)request

    Parameters
    request

    A client request.

    Discussion

    Creates a provisional data source that will transition to a committed data source once any data has been received. Use the  dataSource   method to check if a committed data source is available, and the  stopLoading   method to stop the load. This method is typically invoked on the main frame.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    name

    Returns the web frame’s name.

    - (NSString   *)name

    Return Value

    The web frame’s name.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    parentFrame

    Returns the web frame’s parent web frame.

    - (WebFrame *)parentFrame

    Return Value

    The parent web frame, or  nil   if it has none.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    provisionalDataSource

    Returns the provisional data source.

    - (WebDataSource   *)provisionalDataSource

    Return Value

    The provisional data source, or  nil   if either a load request is not in progress or a load request has completed.

    Discussion

    Use the  loadRequest:   method to initiate an asynchronous client request, which creates a provisional data source. The provisional data source transitions to a committed data source once any data is received.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    reload

    Reloads the initial request passed as an argument to  loadRequest: .

    - (void)reload

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    reloadFromOrigin

    Performs an end-to-end revalidation using cache-validating conditionals if possible.

    - (void)reloadFromOrigin

    Discussion

    End-to-end reload may be necessary if the cache entry has become corrupted for some reason.

    Availability
    • Available in Mac OS X v10.6 and later.
    Declared In
    WebFrame.h

    stopLoading

    Stops any pending loads on the receiver’s data source, and those of its children.

    - (void)stopLoading

    Discussion

    This method does not change the state of the receiver—whatever content has been loaded is preserved.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    Declared In
    WebFrame.h

    webView

    Returns the view object that manages the web frame.

    - (WebView   *)webView

    Return Value

    The view object that manages the entire hierarchy of web frame objects that contains the receiver.

    Availability
    • Available in Mac OS X v10.2 with Safari 1.0 and later.
    • Available in Mac OS X v10.2.7 and later.
    See Also
    Declared In
    WebFrame.h

    windowObject

    Returns the JavaScript window object.

    - (WebScriptObject   *)windowObject

    Return Value

    The JavaScript window object.

    Availability
    • Available in Mac OS X v10.4.11 and later.
    Declared In
    WebFrame.h

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值