Hi folks!
I´m in trouble with this piece of code:
Dim a
Dim R
a=HTMLview1.innerHTML 'it is 12345678
R=InStr ("12345", a)
MsgBox R
The message I got is 0 (zero) but I expected to be 1 (one)
What is wrong?
Thanks
Bob
Hi folks!
I´m in trouble with this piece of code:
Dim a
Dim R
a=HTMLview1.innerHTML 'it is 12345678
R=InStr ("12345", a)
MsgBox R
The message I got is 0 (zero) but I expected to be 1 (one)
What is wrong?
Thanks
Bob
Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)
I think you have the args to InStr reversed.
Thanks for your support
a=HTMLview1.innerHTML 'it is 12345678
R=InStr (a,"12345")
MsgBox R
With this modification, gives the same result (zero)
try alert(a) to see what is being returned.
Just tried it here - I got 1.
a = "123456798"
MsgBox InStr(a, "12345")
a="12345678"
alert ("first " & a)
gives first 12345678
alert ("second " & HTMLview1.innerHTML)
gives second <iframe src="https://www.xxxxxxxxxxxxx"></iframe>
a=HTMLview1.innerHTML
alert ("third " & a)
gives third <iframe src="https://www.xxxxxxxxxxxxx"></iframe>
a=HTMLview1.innerHTML
R=InStr (a,"12345")
alert (R)
gives 0
by the way, https://www.xxxxxxxxxxxxx is not the real content
The problem is with innerHTML, I can see it, and it is 12345678
What does console.log(a) give you?
innerHTML is the contents of a container. In this case, HTMLview1 is the container and it has an iframe control in it.
I’m guessing you’re trying to get the contents of that iframe control. That probably won’t be allowed. You can’t access the contents of an external iframe for security reasons - it would allow scraping of websites along with other issues.
Let´s say an HTMLview is loaded with a wikipedia page content.
I´m able to see what is in that container (picture below).
Could I check for a some part of that content ?
That checking is not allowed for security reason, am I correct?
Here’s an interesting article discussing a possible method for this: