Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

how to switch into iframe?

Post Reply
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: how to switch into iframe?

Post 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.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: how to switch into iframe?

Post 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.
Post Reply