Parameter 'this' - Printable Version +- Antwise community forums (https://forums.antwise.com) +-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11) +--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12) +--- Thread: Parameter 'this' (/showthread.php?tid=168) |
Parameter 'this' - carlos@agpsoftware.com - 2023-09-28 Hi, I'd want to fire a button with this code, but from antview, outside the button. I fon't figure out how to sustitute 'this' in call. onmousedown="iniciarBusqueda('button1',this);" id="viewns_Z7_AVEQAI930OBRD02JPMTPG21004_:form1:button1" type="submit" name="viewns_Z7_AVEQAI930OBRD02JPMTPG21004_:form1:button1" Thanks in advance. Regards. RE: Parameter 'this' - wila - 2023-09-28 (2023-09-28, 15:11:36)carlos@agpsoftware.com Wrote: Hi, Hello, What I do in these cases is to create a simple test html page. Here's my example: PHP Code: <html> I saved the above as "test.html" then opened it in Microsoft Edge. Clicking the button pops up the alert button. So the basics work. Next step... figure out what "this" evaluates to (I have a pretty good idea, but it is best to make sure). The way to do that is to put a breakpoint on the line with the alert. Press F12 while in Microsoft Edge. This will then open Developer Tools for the page "test.html". Go to the tab page named "Sources". Click on "test.html" and put a break point on line 4, see this screenshot: Now click on the button in the test page and you'll find that the break point is hit. You can see the values already, also by hovering with the mouse, but another method to inspect the values in the function are to type the variable names in the console area at the bottom of the screen. As you can see above, the value "this" evaluates to the button object. So if you want to call that function from somewhere else, instead of the onmouseclick, then you can pass the button object instead of "this" and it all should work the same. One way to get the button object in a variable to pass is to use the document.getElementById javascript function. You can figure out the code for that while still in the debug session... eg. see: PS: Please note that you can invoke that same debugger directly from within AntView (also press F12), for more info on that see Debug Anonymous javascript functions PS2: Screenshots are only visible when logged in. -- Wil RE: Parameter 'this' - carlos@agpsoftware.com - 2023-09-29 Hi, Many thanks for answering. Great: I use developper, got object Id and I managed to have it working. m.cscript = "iniciarBusqueda('button1', " m.cscript = m.cscript + 'document.getElementById("viewns_Z7_AVEQAI930OBRD02JPMTPG21004_:form1:button1")' m.cscript = m.cscript + ");" thisform.oantView.executeScript(m.cscript) I'm beggining to hope to convert my project to work with Antview, instead of old IE objects. Thanks again. |