click

Browser-friendly way to simulate anchor click with jQuery?

匆匆过客 提交于 2019-11-30 10:46:56
I'm trying to simulate a click on an anchor tag using jQuery. I've been digging around StackOverflow and Google for a while and haven't found anything that works on all of the browsers I'm testing. So far, I've found this: $(document).ready(function() { $.fn.fireEvent = function(eventType) { return this.each(function() { if (document.createEvent) { var event = document.createEvent("HTMLEvents"); event.initEvent(eventType, true, true); return !this.dispatchEvent(event); } else { var event = document.createEventObject(); return this.fireEvent("on" + eventType, event) } }); }; $('a').fireEvent(

Android button click to play music, click again to stop sound

别等时光非礼了梦想. 提交于 2019-11-30 10:39:00
I have a button, when I click it plays music, how to do it, when I click second time, to stop the music? Button two = (Button)this.findViewById(R.id.button2); final MediaPlayer mp2 = MediaPlayer.create(this, R.raw.two); two.setOnClickListener(new OnClickListener(){ public void onClick(View v) { mp2.start(); } }); Ok, this one works: Button one = (Button)this.findViewById(R.id.button1); final MediaPlayer mp1 = MediaPlayer.create(this, R.raw.n); one.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { if (mp1.isPlaying()) { mp2.pause(); } else { mp2.start(); } ; }});

Simulate click at x/y coordinates using javascript

强颜欢笑 提交于 2019-11-30 10:05:27
How can I simulate a click at x/y co-ordinates using javascript or jquery? I will use the script multiple times and I want the script to click on postion one then postion two then three then four and so one. It is better without moving the mouse cursor, but if it has to move then that is fine as well. This can actually be accomplished with the document.elementFromPoint method. A jQuery example: function simulateClick(x, y) { jQuery(document.elementFromPoint(x, y)).click(); } simulateClick(100, 250); simulateClick(400, 250); Edit: Here is a working example: http://jsfiddle.net/z5YjY/ On a

Click button on website then scrape web page

a 夏天 提交于 2019-11-30 10:04:47
I have a website I would like to click a button on then scrape the website using python the html code between the button is: <span id="exchange-testing" class="exchange-input nav-link" data track="&lid=testing&lpos=site_settings" data-value="testing">Testing</span> Is this possible? I am able to scrape all the data I need from the page but I need to click the button first. Any help would be appreciated Basically, you have two options: high-level approach : automate a real browser using selenium or, in other words, make the browser repeat all the user actions needed to get to the page with the

CefSharp webpage element click

流过昼夜 提交于 2019-11-30 09:26:37
问题 I'm trying to do simple click on some page element(like a btn or link). I have wrote 2 functions for clicking via xpath and via CSS selectors. Both of those functions perfectly works in browser's developer console, but partially does'nt work in CEF. code perfectly click's in simple links from Developer Console and from Cef code perfectly click's on exact button from Developer Console but doesn't do click from CEF. It's just ignore it for some reason... How can this be? Js code is absolutely

jQuery- click at a co-ordinate on an image and draw a circle there

匆匆过客 提交于 2019-11-30 09:07:14
问题 I have a div namely image_preview with an image inside it. There is an input box to get the radius of the circle from the user. When I click at a point on the image, I need a circle with that point as the center and the radius input as the radius. The circle should be marked with a marker . The div with id hotspot_display works as the marker and the div circle acts as the circle to be displayed . Both are absolutely positioned. The marker has as its background an image with the dimension

jquery prevent duplicate function assigned

孤人 提交于 2019-11-30 08:03:41
If I need to assign a click function dynamically, is there a way to ensure the click function is only assigned once and not duplicated? this.click(function(){ alert('test'); }) Marius You can unbind the click event before you bind it again, that way you will only have one event attached to it: //assuming this is a jquery object. this.unbind("click"); this.click(function(){ alert("clicked once"); }); As of jQuery 1.7, click now uses .on ( http://api.jquery.com/click/ ) so the correct code is now //assuming this is a jquery object. this.off("click"); this.click(function(){ alert("clicked once");

How to programatically trigger a mouse left click in C#?

好久不见. 提交于 2019-11-30 07:39:53
How could I programmatically trigger a left-click event on the mouse? Thanks. edit: the event is not triggered directly on a button. I'm aiming for the Windows platform. AlexanderMP https://web.archive.org/web/20140214230712/http://www.pinvoke.net/default.aspx/user32.sendinput Use the Win32 API to send input. Update: Since I no longer work with Win32 API, I will not update this answer to be correct when the platform changes or websites become unavailable. Since this answer doesn't even conform to Stackoverflow standards (does not contain the answer itself, but rather a link to an external, now

Simulating a mouse button click in Windows

僤鯓⒐⒋嵵緔 提交于 2019-11-30 07:39:37
问题 I'm writing Remote Desktop clone in C++ using QT. So far I'm able to move the mouse cursor around fine. QT has a nice setPos function for that. However, I'm a bit lost as to what API/Library to use for simulating mouse button clicks. One method I'm aware of is to send the WM_(event) to a window using the window's HWND. However, I was hoping there was a more salient method for taking complete control over a mouse. Is there any other way to tell the operating system that the left mouse button

Detect both left and right mouse click at the same time?

家住魔仙堡 提交于 2019-11-30 07:33:23
问题 I'm remaking windows Minesweeper (from XP) and something they had included was that if you click a number with as many flags as it's number with the left and right mouse button at the same time, it reveals every other hidden tile around that number. I'm having a hard time telling when both the Left and Right mouse buttons are pressed at the exact same time... I'm using a pair of bools, one for each button with the OnMouseDown and OnMouseUp events but if the 2 buttons are clicked at the exact