我是javascript的新手,并且我正在尝试制作一个程序来连续单击一个按钮,除非存在另一个按钮。 (我也很想在第二个按钮出现时得到警报,但我不知道该怎么做。)
这就是我得到的:
Do {Let button=document.getElementById("find");
Let want= document.getElementById("bba");
setInterval(function(){
button.click();
}, 10000); }
while (want.click=false)
我不断收到错误消息(语法不明)。我不确定该如何解决。
任何帮助将不胜感激!
答案 0 :(得分:0)
仅查看您的代码,我就会看到两个主要错误。首先是您使用大写的do and let,JavaScript区分大小写,因此您需要使用小写字母。第二个是你写的
For Each finalname In filenames
row2 = 1
Using reader As New StreamReader(finalname)
Do Until reader.EndOfStream
Dim line As String = reader.ReadLine
Dim datetimestring As String = line.Substring(0, 22)
datetimestring = datetimestring.Replace("""", "").Trim()
datetimestring = datetimestring.Replace("-", "").Trim()
Dim format As String = "dd/MM/yyyy hh:mm:ss tt"
Dim time As DateTime = DateTime.Parse(datetimestring)
Dim Dt = time.ToString(format)
'Dim dtime As DateTime = DateTime.Parse(Dt)
Dim c As String = line.Substring(22)
c = c.Replace("-", "").Trim()
Dim cmd1 As New SqlCommand("insert into table5([time] , [process], [oven], [line]) values ( @line , @line1, '" & oven & "', '" & row2 & "')", con1)
cmd1.Parameters.Add("@line", SqlDbType.DateTime).Value = time
cmd1.Parameters.Add("@line1", SqlDbType.NVarChar).Value = c
con1.Open()
cmd1.ExecuteNonQuery()
con1.Close()
row2 = row2 + 1
Loop
oven = oven + 2
Dim str20 As String = "data source=10.239.213.40;uid=sa;pwd=Win32API;database=mbi"
Dim con20 As New SqlConnection(str20)
Dim com20 As String = "select top 9 * from table5 where process like '%Load lot clicked%' or process like '%''QCheck'' Button%' or process like '%''Start'' Button%' or process like '%Run Proc%' or process like '%Run Bin2 clicked%' or process like '%Started with Double click%' and oven ='2' order by oven, line desc"
Dim Adpt20 As New SqlDataAdapter(com20, con1)
Dim ds2 As New DataSet()
Adpt20.Fill(ds2, "table5")
DataGridView1.DataSource = ds2.Tables(0)
End Using
Next
您写的是分配而不是相等性检查。
while (want.click=false)
那是编写它的正确方法。
答案 1 :(得分:0)
您应该做的是使用单个setInterval:
window.setInterval(function() {
if (!document.getElementById("button2")) {
document.getElementById("button1").click();
} else {
document.getElementById("button2").click();
alert("second button appeared");
}
}, 100);
抱歉,我在移动设备上。
答案 2 :(得分:0)
您的do和let关键字大写。它们应该是小写。
Let want= document.`getElementById`("bba");
您应在此处使用三等号,而不是赋值运算符。
它应该是:let want === document.getElementById("bba");