Autoclick where is mouse position with javascript - javascript

I have search this kind of post and i didnt find anything.
So my question is :
Is it possible after a time make an auto click on current position mouse?
Example: If mouse is over link blablaba.com click on link or mouse over is over another link so click on that link.
Sorry for my English.
Thank you.
I want to add code on my website, and after a time do autoclick on current position of mouse.

You have this all wrong. Events like "click" are used to trigger function calls. You don't need to trigger the event manually, just call the functions that were about to be called if someone triggered it.
Specifically, if you want the user to land on a new page(that happens when the user clicks a link) you can use redirects

Related

displaying website in popup with javascript on element hover

I am trying to have a dynamic popup window in an html page. the popup will appear when the user hovers a word. and in the popup window i want to call a webpage with the hovered word as parameter. It does not need to work on every word in the page. Only hover on the words i select will work like that.
For example i have a text "hello this is a sample text" in my html page and the user hovers the mouse on the word "sample" a popup will appear and in the popup i will show the following page "www.blabla.com/?word=sample"
hope i was clear.
I want it to be able to work on a static page. I am very new to javascript. I am not even sure where to start so any help would be appreciated.
Thanks.
edit: i want the popup to be a modal popup.
That is very basic, read tutorials on http://www.tizag.com/javascriptT/javascriptevents.php and http://www.w3schools.com/jsref/met_win_open.asp
But I can tell you, that with this sort of method, browsers will trigger their pop up blocker.
Get the elements you want to have this effect, loop over them, add event listeners to each of them which pops a window up.
This is a crude implementation of something like this, where the words have the class popup around them:
[].slice.apply(document.getElementsByClassName('popup')).forEach(function (elem){
elem.addEventListener('mouseover', function (){
window.open('http://google.com/?q=' + this.innerHTML);
}, false);
});​
Demo

cancelling an onclick with a mousemove

I'm not very technical so excuse the following question if it is not phrased properly.
Here it goes:
My site is built with the iscroll javascript so you can click and drag the site to browse. On the portfolio page which currently is the only other slide on from the homepage, I have a thumbnail viewer which enlarges the thumbnail to show the full image, this can be seen at test.silent-g.co.uk
The problem I have, is that when you click and drag to browse back a page, it still activates the viewer, is there a way to code in to the javascript, to cancel the onclick when the mouse is dragged or would this cancel the scroll too?
Excuse the site, the links aren't working and is only a work in progress.
Any thoughts welcome and if answers could be put into laymens terms that'd be great as although I can use javascript I can't write it.
I would suggest you replace onclick with mouseup. This way, it only acts if the user releases the mouse button when the cursor is placed on the element.
The onClick should work propperly. What I tried on jsfiddle was the following.
Html:
<button id="button" onClick="alert(1)">
Your button
</button>
Then just click on the button drag your mouse away from the element and release the mouse. This doesn't trigger the onClick event.

Using BOTH Href & click listener

I've got a browser plug-in I'm working on and I want it to behave a certain way when the user clicks things. Not limited to, but including, a behavior for links!
The problem is that the plug-in has to work for a wide variety of sites, and some of those sites use the dreaded pseudo-protocol such as:
Show Element
Currently my behavior is added to the anchor tag via
anchor.addEventListener('click', superAwesomeFunction);
Unfortunately this has a problem where the click listener only fires once. If I preventDefault() of course the click listener sticks around, but I've now broken the host site! Otherwise, clicking the link fires the click listener but only on the first click. I'm wondering why my superAwesomeFunction() doesn't fire again if the link is clicked a second time. Is href="javascript:things()" doing more than I know?
It is possible to add an event listener to a link that has a JavaScript function call set in the href attribute.
Here's a jsFiddle that shows it working. Both functions fire each time the link is clicked.
There must be something else going on with your code beyond what we can see in what you gave us.
If you must wait user some time and going on url then, you may add some code to your superAwesomeFunction's process end:
document.location.href = $(this).attr("href");

Simulate real mouse click

What I want to do is execute a mouse click say on youtube to press play when the page loads. How do I click that specific location (assuming it is always in the same location)?
I have tried and failed with
var e = document.getElementById('myelem'); e.click();
var e = new jQuery.Event("click");e.pageX=x;e.pageY=y;$("#elem").trigger(e);
and stuff like that. nothing really works. Any suggestions? I am using google chrome
alright it seems like there has been a little confusion so I will further explain. I have created a popup tied to a keystroke event what I want to do is trigger x-webkit-speech by clicking the microphone that is in my popup so that the user does not have to click it themselves. I have tried a bunch of ways like above and have not been successful. After this my program will be done so I really would love some help thanks :]
In general, browsers won't let simulated mouse clicks trigger "real" actions, e.g. a jQuery click() won't cause the browser to follow a link. Otherwise, spammers could trigger banner clicks on every page load (among other more malicious uses).
According to http://www.filosophy.org/2011/03/talking-to-the-web-the-basics-of-html5-speech-input/:
Eventually, it will be possible to invoke the speech-recognition directly with the startSpeechInput() method, but to my knowledge this is not implemented in any of the current browsers.
I suggest waiting for Chrome to implement the API so that you can trigger speech input from JavaScript.
<button id="myButton" onClick="alert('You clicked me!');">Click me</button>
document.getElementById("myButton").click();
http://fiddle.jshell.net/Shaz/HgyeZ/
That's with regular clickable items though. But with YouTube Videos, you could also append &autoplay=1 to the end of the url (if it's embedded into a page).
http://fiddle.jshell.net/Shaz/tcMCa/

How to fire button click event from user contol in asp.net

I have a time on user control, and button on the web page. On perticular time I want to fire button click event. Please tell me how do this.
.click javascript method will help you.
document.getElementById("buttonId").click();
If you want the button clicked code to run after five seconds, for example, you would do the following.
setTimeout("document.getElementById(\"buttonId\").click();", 5000)
This link has basic information about timing in JavaScript.
It would be helpful if you could tell us more about the particular time-related user control you are using.

Categories