javascript - Simulate keyboard input in browser (noticable by React) - javascript

I'm trying to make a js macro which will fill 3 inputs needed for login. I need to make this a lot of times in a day, so this would help a lot.
The problem is that something so simple like:
input_name.value = 'somevalue'
won't work, because the page I'm login into is using React.
I think I need to simulate pressing a keyboard key somehow.
Is it possible? I tried a lot of methods, but none worked.
I also tried few Chrome plugins for this (like iMacros), but all of them doesnt 'trigger' React's mechanism.
Anyone have some solution?

iMacros should be able to simulate keypress using firefox/chrome plugins. iMacros EVENT Documentation
If that doesn't work you could use a hardware solution such as a Teensy which can act as a keyboard/mouse

Related

Find the JS and jQuery codes and functions behinde an event in a web page quickly

When an event occur in a web page maybe a function be ran, of course if web designer has been assigned some codes to it and make require links.
But there are different ways to link the codes and events, especially when we are using a framework like jQuery! For example when we want assign a function to Click event of a Button or Checkbox , we can find it by different selectors and do this in the web page or in an external JS file and import it and....
Now i want now what are your suggestions to find the codes under an events (for example click event on a Checkbox) quickly.
Which lines and where?
I now i can discover the web site codes and pages to find it but i'm looking for a quick way and want know what is your suggestions...
Do you recommend some tools? Please explain them.
Developer Tools in your browser will help, and the search function build in

Using data return from sharepoint assetimagepicker

I'm working with Sharepoint 2007. I use the built in AssetImagePicker.aspx and I need to retrieve the image url from that page and use it in my custom webpart.
I want to run my javascript code to run when clicking the OK button of the AssetImagePicker.aspx but I can't find a way to do that.
Does anyone know how to do this?
Thanks
Not sure if I'm understanding the question properly, and I know nothing about Sharepoint (and AssetImagePicker.aspx) but it sounds like you want to add an event handler to the OK button: to run a function when the click event of the button is fired.
You can either code event handling yourself (see W3Schools or Quirksmode for examples of this) or (probably better) use a library like jQuery.

Make onClick event work for visually impaired

I got a problem with a website that use onClick event to add items to the cart. The problem comes up to visually impaired users that cant use keybord to add the products.
I guess that bringin back the add function with a normal href="addtocard.php?id=1234" should solve the problem but on the SEO side this can effect other problems.
Is there any other way, maybe using events such as onkeypress, or that's totally related to the use of javascript? Thanks in advance.
Having an addtoCart.php?ID=5 should not have a detrimental impact on your SEO. Modern/top search engines will be smart enough to recognise what the function of that page is, and index it accordingly.
When designing sites, I forget the specific name of this type of design, but it is always best to build it upwards, that is add on the onclick/javascript functionality as an extra over the top of the base of your site, so that if users have any of these features disabled the site will still function perfectly, so that is something to consider when building your next site.
So I would recommend building the addtoCartPage. I don't think it's as bad as you think it is.
You can use something like this
Add To Cart
Or somethinkg like this
Add To Cart
It's the other way around from what your SEO consultant said. Most visually impaired people prefer keyboards. It's mice they can't use so well. The name makes you think that onclick only works with a mouse, but in general, onclick works fine for the visually impaired/non-mouse users, since it is triggered with the Enter key as well as with a mouse click. See http://webaim.org/techniques/javascript/eventhandlers#onclick.
That's why using onkeypress for accessibility is not a good idea. Jeremy Keith flatly says, "Beware of onkeypress" since even a Tab key could make it fire.
Besides progressive enhancement in general, you might try Unobtrusive Javascript in particular, which uses Javascript to rewrite links, and that means users without Javascript get regular HTML links. If Google can't follow your Javascript links, you do have an SEO problem.

Listen to HTML/CSS events of web page

I'm looking for a way to listen for an event in the HTML/CSS of a webpage. Basically, a website I use at work lists queues and appointments, which flag as yellow/red based on the amount of time late on taking said appointment. Other than this visual aide, there is no alert of any kind, which is a failing point if one is juggling multiple windows and doesn't notice.
What I would like to do is put together a simple way to watch for the tag ID or perhaps the flag hex color, and then alert me in a way of my choosing.
The work environment is on OS X, so I presume I'm looking at an Objective-C centric solution unless Applescript is capable of doing this.
Any help would be greatly appreciated.
I know you didn't tag jQuery, or JavaScript, but a custom bookmarklet may be the solution.
As it so happens I created a bookmarklet utility a while back so that you can keep your bookmarklet in an external script file.
You could then have alert or confirm called automatically for some event on the page.
Are you able to specify the browser your users use? If so, Chrome has support for HTML5's out of browser notifications, ala: http://slides.html5rocks.com/#notifications-api
You could get a reference to the dom elements you want to monitor, and use setInterval() to poll the data you are looking for on some interval, alerting when it changes.
See this fiddle for an example.

What happens to my web application if JavaScript is disabled?

I'm learning jQuery and am about to write some pages using intensively that library. I just learned that some user disable JavaScript on their browser (I didn't even know that was possible and/or necessary).
Now, here's my question: What happens to my web application if a user disable JavaScript? For instance, I'd like to display some screens using AJAX and commands such as 'InsertBefore' to bring in live a DIV that will display the result.
So, if JavaScript is disabled, I wonder what going to happen to all this work that relies on JavaScript?
I'm kind of lost.
Thanks for helping
You may want to start by reading on Progressive Enhancement and Unobtrusive JavaScript.
I would also suggest to investigate how popular rich web applications like GMail, Google Maps and others, handle these situations.
I just learned that some user disable javascript on their browser
I do. The "NoScript" plugin for FireFox does the trick.
So, if Javascript is disabled, I wonder what going to happen to all this work that relies on Javascript?
It won't be functional.
A good practice suggests designing a site not to rely on JavaScript for major functionality. At least, accessing its content (in read-mode) should be possible. JavaScipt should only add interface enhancements like Ajax techniques etc. But the fallback version should always work.
I feel really sad when I see a site which is completely broken without JavaScript. Why can't people use CSS to put elements in proper places? Why do they try to align elements with JavaScript even if there is no dynamics involved?
The same goes for Flash sites. Once in a while a land upon a "web-design-agency" site which makes picky comments about me not allowing JavaScript. When I do I only see a basic primitive site with a few menus and that's it. What was the point of using Flash when the work is so primitive it can be done with raw HTML and CSS in an hour? For me it's a sign of unprofessional work.
All what's done in JavaScript won't work. Some users disable it for security reasons, NoScript is an excellent example. You can try it yourself by removing the scripts from your page or installing the NoScript-plugin for Firefox.
As a rule of thumb:
Make the website working with only semantic HTML
add the CSS
add the JS
But the website should be (almost) fully functional in stage 1.
If you disable Javascript in Safari things like Lexulous in Facebook won't work properly, the mouse letter carry function doesn't work.

Categories