Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

I want to return the html and text of a selection on a web page

Public ie
ie=Createobject('internetexplorer.application')
ie.Visible=.T.
iet.navigate2("www.somewhere.com")

Open in new window


I want to be able to highlight a section of a webpage and from foxopro return the text of the selection and return the html of the selection simular to firefox's copy selected html function. I know there is a way, I have just forgeotten it. :(

Thanks again all!!!!!!
0
busycoder
Asked:
busycoder
  • 4
  • 2
  • 2
2 Solutions
 
CaptainCyrilCommented:
? ie.Document.Body.InnerText

You can use GetElementByName('ElementName').InnerText or InnerHTML
0
 
busycoderAuthor Commented:
I want to only return the text of what I have selected on a given page with the mouse.

Ie.document.selection (I think is where to start)

I want to the HTML of that portion only. I know I figured this out before but am drawing a blank still.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Olaf DoschkeSoftware DeveloperCommented:
Youre on the right track. The problem is, VFP does not display the methods and properties of the selection object by intellisense, if you type Ie.document.selection, VFP does not even display the selection subobject of ie.document, even though it's there. That's a bit of a glitch of VFP's intellisense, VFP can only display what it can see, the selection subobject seems somehow virtual, created on the fly as you access it. You can do so, by storing it to a VFP variable:

oDoc = ie.document

Now you can see oDoc.selection and it's methods and the type property.  And you can also see there is a createRange method (which the reference Cyril gave you also tells - http://msdn.microsoft.com/en-us/library/ms535869%28VS.85%29.aspx). And the Range object has a htmlText property giving you the HTML of the selection.

I did only learn that right now by inspection via intellisense, it was simply try and error, there was not much more I could test, the selection object itself has not many choices. The general idea I want to share is, that you can do that too and learn from intellisense. And if intellisense seems blind or dim, enlighten it by creating a new root object in a new variable and it most probably can see further from there.

Now here's the full code:

oIE = Createobject('internetexplorer.application')
oIE.Visible = .T.
oIE.navigate2("www.somewhere.com")

* make a selection of some text portion

oDoc = oIE.document
oTextRange = oDoc.selection.createRange()
? oTextRange.htmlText
? oTextRange.Text

Open in new window

0
 
busycoderAuthor Commented:
Thank you again guys!! Olaf, I think you told me about the intellisense trick before, but I didn't get it, thanks for telling me again, that is VERY valuable. CaptainCyril, thank you again for some great reference links as always. You both are always such a HUGE help to me. Lets do lunch!
0
 
CaptainCyrilCommented:
Where? In Beirut, Lebanon? Anytime :-)
0
 
Olaf DoschkeSoftware DeveloperCommented:
Of course we could lunch together somewhere.com, sometimes.com

Bye, Olaf.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now