Page 1 of 1

Re: how to switch into iframe?

Posted: Thu Jun 28, 2018 7:56 pm
by salvadordf
lifeform wrote: Thu Jun 28, 2018 6:38 pm hello
is there any solution to switch into iframe?
how i can get access into spesific iframe? i need run javascript in spesific iframe.
could you help me which demo have clue about this?
Use TChromium.ExecuteJavaScript and select the frame with the 3rd parameter.

To get the frame names use TChromium.GetFrameNames and to get the frame identifiers use TChromium.GetFrameIdentifiers.
TChromium.FrameCount will tell you how many frames currently exist.

Re: how to switch into iframe?

Posted: Fri Jun 29, 2018 8:16 am
by salvadordf
lifeform wrote: Fri Jun 29, 2018 1:48 am what you mean with 3rd parameter? is this executeJavaScript 3rd parameter is "startLine"?
TChromium defines these 3 overloaded functions :
  • TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameName : ustring = ''; aStartLine : integer = 0);
  • TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrame : ICefFrame; aStartLine : integer = 0);
  • TChromium.ExecuteJavaScript(const aCode, aScriptURL : ustring; const aFrameIdentifier : int64; aStartLine : integer = 0);
The third parameter can be the frame name, an ICefFrame or the frame identifier.
lifeform wrote: Fri Jun 29, 2018 1:48 am but how to know the frame id from html so i do not send all code to every single frame?
You can use the name attribute or use any TChromium event with an ICefFrame parameter like TChromium.OnLoadEnd, check the ICefFrame.URL and use ICefFrame as the third parameter in ExecuteJavaScript.

You can also set the focus in a known HTML element and use ICefFrame.IsFocused in a TChromium event to identify the frame.