|
Rank: Newbie Groups: Member
Joined: 1/14/2015 Posts: 6
|
Hi, I'm trying to auto-fill inputs to a site with a form in a iFrame. I found this http://www.essentialobjects.com/forum/postsm35053_EOWebBrowser--auto-login--Vbnet.aspxIt works but there is a problem if my inputs are in a iFrame it's doesn't fill my inputs. I guessed it's because the url in my webView wasn't the one in the iFrame but in the global document. I tried webView.LoadUrlAndWait(urlofMyIFrame);. and after I used webView.EvalScript(evalscriptValue);. It doesn't work and it loads the document of the iFrame in my web browser as my main document. How can I auto-fill inputs in a iFrame and keep the main document in my web browser? Also InnerText, like in the example in the link, doesn't contain a setter
Code: C#
EO.WebBrowser.DOM.Document doc = WebView1.GetDOMWindow().document;
doc.getElementById("username").innerText = user_name;
Thank you for your support.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, In order to do this you must: 1. Set EnableWebSecurity browser option to false. For example, you can set it like this before creating any WebView:
Code: C#
EO.WebBrowser.BrowserOptions options = new EO.WebBrowser.BrowserOptions();
options.EnableWebSecurity = false;
EO.WebBrowser.Runtime.SetDefaultOptions(options);
2. You can then use something like this to fill input:
Code: C#
webView1.EvalScript("frames[frame_name].document.getElementById('user_name_id').value='user_name';");
Here you need to replace: 1. "frame_name" with the actual frame name; 2. "user_name_id" with the actual Id of the user name textbox; 3. "user_name" with the actual user name; The key is use frame[frame_name].document to get the document object for the iframe. However in order to do so you must set EnableWebSecurity to false first. Hope this helps. Please feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2015 Posts: 6
|
Hi, Thank you it works! I also have another problem presented in this thread: http://www.essentialobjects.com/forum/postst8748_Circumvent-Content-Security-Policy.aspxThank you to let me know if you are going forward with the idea.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
These two are two different measures. This one is related to same origin script policy and it can be turned off. That one is is related to the header entry and it can affect not just JavaScript, but any kind of resource (images, font, CSS, etc) and it is not possible to turn it off. Another very important distinction is, EnableWebSecurity affects executing time behavior (JavaScript code from one origin can not access DOM from another origin) and is enforced by the JavaScript engine, where as Content-Security-Policy affects load time behavior and is enforced by the resource loader. So they are really very different.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/14/2015 Posts: 6
|
Hi,
I was talking about an another website for Content Security Policy, not the one with iFrame, sorry about the confusion.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
No problem. Please feel free to let us know if you have any other questions.
|
|
Rank: Newbie Groups: Member
Joined: 5/13/2016 Posts: 5
|
FYI - the example code above seems to have changed...
In VB it is...
Dim options As New EO.WebEngine.BrowserOptions options.EnableWebSecurity = False EO.WebBrowser.Runtime.SetDefaultBrowserOptions(options)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Ioannis wrote:FYI - the example code above seems to have changed...
In VB it is...
Dim options As New EO.WebEngine.BrowserOptions options.EnableWebSecurity = False EO.WebBrowser.Runtime.SetDefaultBrowserOptions(options) Yes. Thanks for sharing!
|
|