-
Apr 16th, 2020, 11:36 AM
#1
Thread Starter
Lively Member
How to Call function in .JS file | Pass 2 parameters | Get Result as String
I'm trying to call a javascript function from within VB6.
Details:
* The javascript function is contained in a file named "htmlparser.js" and this file is installed along side the .EXE file when the application is installed.
* The function is called "parse" and it takes 2 parameters: URL and HTML
The function call looks like this:
Code:
htmlparser.parse(url, {html: '<html><body><p>Some HTML to be Parsed</p></body></html>',}).then(result => console.log(result));
How can I call this function from VB6 and retrieve the result into a string variable? Do I use .execscript or wscript or what?
TIA
-
Apr 16th, 2020, 06:20 PM
#2
Re: How to Call function in .JS file | Pass 2 parameters | Get Result as String
-
Apr 17th, 2020, 10:29 AM
#3
Re: How to Call function in .JS file | Pass 2 parameters | Get Result as String
You don't need any javascript-support, to read-out the plain-text from some HTML-Document-input
(if that's what you are after, which isn't entirely clear)...
FWIW, here's a simple function, which does just that:
Code:
Private Sub Form_Load()
Debug.Print HtmlToText("<html><body><p>Some HTML to be Parsed</p></body></html>")
End Sub
Function HtmlToText(sHTML As String) As String
With CreateObject("htmlfile")
.write sHTML: HtmlToText = .body.innerText
End With
End Function
Olaf
-
Apr 17th, 2020, 10:55 AM
#4
Thread Starter
Lively Member
Re: How to Call function in .JS file | Pass 2 parameters | Get Result as String
Can I access the the functions in v8.dll from VB6? Can I just add v8.dll via the References menu and call its functions?
-
Apr 17th, 2020, 10:58 AM
#5
Thread Starter
Lively Member
Re: How to Call function in .JS file | Pass 2 parameters | Get Result as String
This JS parse function produces clean HTML so you get the text portion without losing the links and images.
-
Apr 17th, 2020, 11:23 AM
#6
Re: How to Call function in .JS file | Pass 2 parameters | Get Result as String
Originally Posted by zlander
This JS parse function produces clean HTML so you get the text portion without losing the links and images.
Without any example-outputs (and the source of htmlparser.js), this will remain a "guessing-game".
Olaf
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|