Skip to content

Latest commit

 

History

History
287 lines (181 loc) · 6.25 KB

Frame.md

File metadata and controls

287 lines (181 loc) · 6.25 KB

API categories | API index

Frame (object)

Remember to free all frame references for the browser to shut down cleanly. Otherwise data such as cookies or other storage might not be flushed to disk when closing app, and other issues might occur as well. If you store a reference to Frame somewhere in your code then to free it just assign a None value to the variable.

To compare frame objects always use GetIdentifier() method. Do not compare two Frame objects variables directly. There are some edge cases when after the OnBeforeClose event frame objects are no more globally referenced thus a new instance is created that wraps upstream CefFrame object. Frame objects that were globally unreferenced do not have properties of the original Frame object.

Table of contents:

Methods

Copy

Return void

Execute copy in this frame.

Cut

Return void

Execute cut in this frame.

Delete

Return void

Execute delete in this frame.

ExecuteFunction

Parameter Type
funcName string
.. *args
Return void

Call a javascript function asynchronously. This can also call object's methods, just pass "object.method" as funcName. Any valid javascript syntax is allowed as funcName, you could even pass an anonymous function here. For a list of allowed types of arguments see JavascriptBindings.IsValueAllowed() - except function, method and instance. Passing a python function here is not allowed, it is only possible using the JavascriptCallback object.

ExecuteJavascript

Parameter Type
jsCode string
scriptUrl="" string
startLine=1 int
Return void

Execute a string of JavaScript code in this frame. The sciptUrl parameter is the url where the script in question can be found, if any. The renderer may request this URL to show the developer the source of the error. The startLine parameter is the base line number to use for error reporting. This function executes asynchronously so there is no way to get the returned value. Calling javascript <> native code synchronously is not possible.

GetBrowser

Return Browser

Returns the browser that this frame belongs to.

GetParent

Return Frame

Returns the parent of this frame or None if this is the main (top-level) frame.

GetIdentifier

Return int

Frame identifiers are unique per render process, they are not globally unique.

Returns < 0 if the underlying frame does not yet exist.

GetBrowserIdentifier

Return int

Returns the globally unique identifier for the browser hosting this frame.

GetName

Return string

Returns the name for this frame. If the frame has an assigned name (for example, set via the iframe "name" attribute) then that value will be returned. Otherwise a unique name will be constructed based on the frame parent hierarchy. The main (top-level) frame will always have an empty name value.

GetParent

Return Frame

Returns the parent of this frame or None if this is the main (top-level) frame. This method should only be called on the UI thread.

GetSource

Parameter Type
visitor StringVisitor
Return void

Retrieve this frame's HTML source as a string sent to the specified visitor.

GetText

Parameter Type
visitor StringVisitor
Return void

Retrieve this frame's display text as a string sent to the specified visitor.

GetUrl

Return string

Returns the url currently loaded in this frame.

IsFocused

Return bool

Returns true if this is the focused frame. This method should only be called on the UI thread.

IsMain

Return bool

Returns true if this is the main (top-level) frame.

IsValid

Return bool

True if this object is currently attached to a valid frame.

LoadString

Parameter Type
value string
url string
Return void

NOTE: LoadString is problematic due to the multi-process model and the need to create a render process (which does not happen with LoadString). It is best to use instead LoadUrl with a data uri, e.g. LoadUrl("data:text/html,some+html+code+here"). Take also a look at a custom resource handler.

Load the contents of |value| with the specified dummy |url|. |url| should have a standard scheme (for example, http scheme) or behaviors like link clicks and web security restrictions may not behave as expected. LoadString() can be called only after the Renderer process has been created.

LoadUrl

Parameter Type
url string
Return void

Load the specified |url|.

Paste

Return void

Execute paste in this frame.

Redo

Return void

Execute redo in this frame.

SelectAll

Return void

Execute select all in this frame.

Undo

Return void

Execute undo in this frame.

ViewSource

Return void

Save this frame's HTML source to a temporary file and open it in the default text viewing application.