Jump to content

How to remove or block a webpage's inputbox event


Recommended Posts

Quote

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>InputEvent</title>
</head>
<body>
<form name="input" action="html_form_action.php" method="get">
    <label>Text: <input type="text" id="text"/></label>
    <br>
    <label for="sel">Select:</label>
    <select name="sel" id="sel">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
    </select>
    <br>   
    <label for="r1">r1</label><input type="radio" name="radio" value="r1" id="r1">
    <label for="r2">r2</label><input type="radio" name="radio" value="r2" id="r2">
    <label for="r3">r3</label><input type="radio" name="radio" value="r3" id="r3">
    <label for="r4">r4</label><input type="radio" name="radio" value="r4" id="r4">
    <label for="r5">r5</label><input type="radio" name="radio" value="r5" id="r5">
    <br>
    <label for="tta">TextArea:</label>
    <textarea name="tta" id="tta" cols="30" rows="10"></textarea><br>
    <input type="submit" value="Submit"><br>
    </form> 
<script>
    var text = document.getElementById("text");
    text.addEventListener("input", function (e) {
        document.getElementById("tta").value=e.target.value;
    });
</script>
</body>
</html>

As above,

the web-page inputbox has input events, input characters, below the textarea real-time display.

If want to disable inputbox events, how do  implement them with Au3?
 

#include <IE.au3>

Local $oIE = _IEAttach("InputEvent - Internet Explorer","windowtitle")
If IsObj($oIE) Then
    Local $oInput=$oIE.document.getElementById("text")
    If isObj($oInput) Then
        $oInput.removeEventListener("input",'function',false)
        If @error Then MsgBox(4096,"","failure!")
    EndIf
Else
    MsgBox(4096,"","$oIE--failure!")
EndIf

that don't work,

I am not familiar with javascript functions and syntax, I can only following suit, I do not know how to further...

Thanks for the help Early advance!
 

Edited by Letraindusoir
Link to post
Share on other sites
  • 4 months later...
5 hours ago, Letraindusoir said:

Words are misspelled, but have nothing to do with this

you think you can misspell document and it should still work?

Local $oInput=$oIE.docunment.getElementById("text")

 

Code hard, but don’t hard code...

Link to post
Share on other sites
Posted (edited)
17 hours ago, JockoDundee said:

you think you can misspell document and it should still work?

Local $oInput=$oIE.docunment.getElementById("text")

 

The above are just simple example to explain what want to ask.. 
Because what  really needs to solve is an internal web site, there is no way to provide links for testing. The webpage seems to use dojo、bootstrap, etc. , web elements layer by layer nested, binding events are more complex.It would be nice to have a general method of temporarily disabling events or similar examples...

Edited by Letraindusoir
Link to post
Share on other sites
10 minutes ago, Letraindusoir said:

The above are just simple example to explain what want to ask.. 

Ok, sure, but in your OP you posted some code that contained the misspelling “docunment”, and then you said:

On 1/15/2021 at 1:14 AM, Letraindusoir said:

that don't work,

 So the question would now be, have you even tried the code you posted (with the misspelling) ?

If not, why not?  If so, why not try it with the correct spelling?

Code hard, but don’t hard code...

Link to post
Share on other sites
43 minutes ago, JockoDundee said:

Ok, sure, but in your OP you posted some code that contained the misspelling “docunment”, and then you said:

 So the question would now be, have you even tried the code you posted (with the misspelling) ?

If not, why not?  If so, why not try it with the correct spelling?

with the correct spelling,The above code don't work for me.....

:mad:

Link to post
Share on other sites
Posted (edited)
On 1/15/2021 at 3:14 AM, Letraindusoir said:

If want to disable inputbox events, how do  implement them with Au3?

If you did your homework before creating this topic, then I'm sure that you found that removing anonymous events, using removeEventListener(), cannot be done because there's no reference to them.  However, based on your specific sample html & request above, there is a very simple solution.  Since the anonymous events for the "Text" field are added based on an element node with an id equal to "text", you can "unhook" the events from the element by simply changing the element's ID or by removing the definition of the event, and rewriting the HTML.  The example below changes the element's ID:

#include <Constants.au3>
#include <IE.au3>

example()

Func example()
    Local $oIE = Null, $oNode = Null

    ;Attach to existing IE instance
    $oIE = _IEAttach("InputEvent", "windowtitle")
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Unable to attach to IE with specified title.")

    ;Get node with id = text
    $oNode = _IEGetObjById($oIE, "text")
    If @error Then Exit MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "No matching object id found.")

    ;Change node's ID. This will invalidate anonymous functions tied to the old ID.
    $oNode.id = "newid"

    ;Rewrite modified document
    _IEDocWriteHTML($oIE, $oIE.document.documentElement.innerHtml)

    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", 'Try typing text in the "Text" box now.')

EndFunc

 

Edited by TheXman
Removed unused variable
Link to post
Share on other sites
19 hours ago, TheXman said:

However, based on your specific sample html & request above, there is a very simple solution.  

Thanks chivalrous expert for giving directions!

As posted above, that' s just using a simple example explaining the question I want to ask.

The actual web-page seems to be using the dojo、bootstrap component constructed element to respond to events,

so I hope there would be a more common way to ban elements from responding to events.

For example, after positioning to an element, deactivate it in some way

Link to post
Share on other sites
Posted (edited)

 

I try very hard NOT to make assumptions as to what a person is asking or wants. Making assumtions usually ends up wasting time and gives that person a way to say that's not what they were looking or asking for.  Therefore, I only work with what I've been given and the answers to any followup questions that are asked.  So, if you provide overly-simplified examples and requests, don't be surprised when you receive overly-simplified replies.  In other words, as it says in my signature, if you want better answers, learn how to ask better questions.  You may benefit from reading one or both of those articles.

 

54 minutes ago, Letraindusoir said:

The actual web-page seems to be using the dojo、bootstrap component constructed element to respond to events,

The statement above, without accurate, detailed, examples, is almost useless.  It's like telling a mechanic that you have a car with a V8 engine, and other assorted non-specific performance modifications, and asking the mechanic how to improve its performance or make further modifications without seeing the car itself or a detailed list of parts and specs.  That would be a fool's errand;)

 

54 minutes ago, Letraindusoir said:

so I hope there would be a more common way to ban elements from responding to events.

You already stated that you are "not familiar with JavaScript functions and syntax".  So how do you know what you want or need or what is a "more common way"?  There are numerous ways to do what you are asking but it depends on the specifics of any given web page. I discussed a couple of them above based on what you provided.  I even provided an example of one of the ways.  But without seeing what you are working with, how is anyone supposed to help you learn how to resolve your specific issue?  :think:  If you are going to be playing around with web pages, maybe you should spend a little more time learning those technologies.  That way you can ask more informed questions, better understand the replies that you receive, and then ask more intelligent followup questions in order to learn how to do what it is you need/want to do.

Edited by TheXman
Link to post
Share on other sites
1 hour ago, TheXman said:

I try very hard NOT to make assumptions as to what a person is asking or wants.

just Because not familiar with JavaScript functions and syntax, and the source site is a non - public  java - based application,so it is impossible to specify the problem too clearly and provide specific complex web-pages.sorry! 

I only know that it introduces the dojo、bootstrap components.

I thought that as long as we positioned the specific elements, we could put a brake or plug a pin on it, and it seemed that I thought it was simple. 
I tried to use VisualEvent to track events but had no gains.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...