Hy
I want to display Html web page from Logo! Siemens PLC how need login user on LS224. I try method in post HTML5-page-with-login
I update code ttlogin.js
m.htmlwidget.InjectJavaScript("if(document.getElementById('loggedIn').style.display='none'){
document.getElementById('input_username').value='Web User';
document.getElementById('input_password').value='FMD3918';
document.getElementById('button_login').click();
};")
and sendWebLogin.brs
Function sendWebLogin_Initialize(msgPort As Object, userVariables As Object, bsp As Object)
sendWebLogin = newSendWebLogin(msgPort, userVariables, bsp)
return sendWebLogin
End Function
Function newSendWebLogin(msgPort As Object, userVariables As Object, bsp As Object)
'create the new object
s={}
s.objectName = "sendWebLogin_object"
s.msgPort = msgPort
s.userVariables = userVariables
s.bsp = bsp
s.htmlwidget = invalid ' We'll use the FindHTMLWidget method to set this later
s.ProcessEvent = sendWebLogin_ProcessEvent
return s
End Function
Function sendWebLogin_ProcessEvent(event As Object) as boolean
m.htmlwidget = FindHTMLWidget(m.bsp) 'find the htmlwidget in the presentation
'Receive a plugin message
if type(event) = "roHtmlWidgetEvent" then
eventData = event.getData()
if type(eventData) = "roAssociativeArray" and type(eventData.reason) = "roString" then
print "event data reason ==>"; eventData.reason
if eventData.reason = "load-finished" then
print "calling javascript login"
m.htmlwidget.InjectJavaScript("document.getElementById('input_username').value='Web User';document.getElementById('input_password').value='FMD3918';document.getElementsByTagName('button_login').Click();")
end if
end if
end if
return false
End Function
Function FindHTMLWidget(bsp)
for each baZone in bsp.sign.zonesHSM
if baZone.loadingHtmlWidget <> invalid then
return baZone.loadingHtmlWidget
end if
end for
print "Couldn't find htmlwidget"
return false
End Function
Page not login
In browser console when execute ttlogin.js this error appear:
ttlogin.js:1 Uncaught SyntaxError: Invalid or unexpected token (at ttlogin.js:1:31)
Anyone can help me?
PS: I'm newbe in BS and Script