javascript - 查找通过 JavaScript 函数传递的变量的值

标签 javascript vba

我对 JavaScript 不是很熟悉 - 如果我的解释没有意义,请原谅我。我正在尝试执行一个使用我找不到的变量的 JavaScript 函数。以下是页面源代码中的 JavaScript 函数。

function viewObjectionLetter(letterId)
{
    objLetterWindow = window.open('viewObjectionLetter.do?filingId=12345678&letterId='+letterId+'&viewOnly='+isEditUpdateMode(),'objectionLetterWindow','scrollbars,resizable,height=500,width=960');
    return false;
}

来源显示,当点击链接时,它会执行以下功能。

viewObjectionLetter('13579');return false;

在 VBA 中

调用 CurrentWindow.execScript("viewObjectionLetter('letterId')")

返回网页错误,url 显示 letterId 没有值。如何从页面中找到该值以执行该功能?

谢谢。

编辑: 这是完整的源代码。

Sub loadSERFF()

Dim ie As New InternetExplorer
Dim user As String
Dim pass As String
Dim product_name As String
Dim project_number As String
Dim author_name As Variant
Dim btn As Variant
Dim objs As New Collection
Dim coTrack As New Collection
Dim respondBy As New Collection
Dim productName As New Collection

user = Range("A2").text
pass = Range("B2").text

'Set IE = InternetExplorer.Application
ie.Visible = True
ie.Navigate "https://login.serff.com/serff/signin.do"

Do
DoEvents
Loop Until ie.ReadyState = 4

'Must NOT already be logged into SERFF
Do
ie.Document.forms(0).all("userName").Value = user 
ie.Document.forms(0).all("password").Value = pass
ie.Document.forms(0).submit
Loop Until ie.ReadyState = 4

Call pageLoad (ie)

ie.Navigate "https://login.serff.com/serff/viewOpenFilings.do"

Call pageLoad(ie)

'Need to account for multiple pages of open filings *IMPORTANT*
Set objectionsTags = ie.Document.getElementsByTagName("td")

i = 1
For Each objection In objectionsTags
    If InStr(LCase(objection.innerHTML), "pending industry response") Then
        coTrack.Add (objectionsTags(i - 4).innerHTML)
        productName.Add (objectionsTags(i - 5).innerHTML)
        i = i + 1
    Else
        i = i + 1
    End If
Next objection

ie.Document.forms(0).all("trackingNumber").Value = coTrack(1)
Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = ie.Document.parentWindow
Call CurrentWindow.execScript("performQuickSearch('company');")

Call pageLoad(ie)

Call CurrentWindow.execScript("updateTab('objections');")

Call pageLoad(ie)

Call CurrentWindow.execScript("viewObjectionLetter('letterId')")

Call pageLoad(ie)

End Sub

最佳答案

Call CurrentWindow.execScript("viewObjectionLetter('letterId')")

这会将字面值“letterId”传递给函数,这不会让您到任何地方。您需要找到实际值并传递它。

您可以从页面源代码中提取它,但由于您没有显示任何 HTML,因此很难建议如何做到这一点。

为什么不直接点击链接呢?

关于javascript - 查找通过 JavaScript 函数传递的变量的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42009804/

相关文章:

javascript - 与 redux react 生成的静态 SEO 友好页面,我只需要索引页面

excel - 使用鼠标按钮更改单元格值 - Excel

excel - VBA:如何检索 HeaderRowRange 中给定元素的 ListObject-Column-Count?

vba - 使用按钮根据值播放Excel中的声音

javascript - 从 angularJS 中的回调内部更新 $scope

javascript - JSON-LD 到 HTML 模板引擎

javascript - 获取数组的每四分之一并检查

javascript - 检查字符串是否以括号中的数字开头

Excel VBA 输入框

vba - 使用 VBA 在 Office 中压缩图像