HTML Viewer Form Variables

I may have asked this before, but can’t find it.

Is there any way to set form variables when using the HTML Viewer control?

DesktopHTMLViewer yes
WebHTMLViewer no

How you do so depends on the form. If each field has an ID, it’s repetitively simple. If not, you’ll have to iterate the DOM to find the fields to fill.

Here is more information.

I have an iOS app that has several tabs just wrapping pages from a web site.
The site is username password protected. I want my app to automate login so that they don’t have to log in through the web page.

I have an option to pass form variables to the page (user name and password) with a parameter next so that it will appear to the user that they only logged in at the level of my app. Requesting that URL will authenticate the user and move them along to the desired page.

Does that make sense?
Can that be done?

You run JavaScript to set form value.

e.g.

document.MyForm.MyField.value = 123;

or similar

I guess this means I would have to load the url into the browser first right?

Yes. According to the documentation you’ll need MobileHTMLViewer to use ExecuteJavascript. You can use an onload trigger to load the page and have it fill the form then submit automatically. Watch the DocumentComplete event for your final logged in destination.

1 Like

I’ve never played with this stuff before. I’ll dig in now.

Thanks, everybody, for the suggestions.

Do you control the website? Is it your’s?

If so, then there are better ways to login, otherwise you probably put username and password in your code and they are therefore compiled into the app. This is a security risk, I would avoid.

We do control the web site. We’re looking for a quick fix for prototyping.
And no, I won’t put the user name and password in the code. That will be requested at the app level (not browser level) from the iOS app.

1 Like

looks like your Web Viewer Control allows me to set header values in a request.
I can work with our developer to read those and get to the needed solution in a much more elegant manner.

1 Like