Getting Different Behaviors For Clicking On An Image Vs Holding The Mouse Down

Jul 20, 2005

I'm working on a small javascript application where I'd like to get one
behavior when a user clicks on an image (image swap), but when they
simply hold down the mouse button for a second, they get another
behavior (drop down menu).

The former seems pretty easy -- just assign the handler for the onClick
event to the swapping function. The latter, however, seems more
involved.... I know I'd assign the onMouseDown handler to a different
function, and then.... after a 1 second or so I'd want to test whether
or not the mouse buttom was still being held down. Except that I have no
idea how to do that (both the waiting part and the actual test itself).

The idea that does occur to me is to have some kind of data structure
associated with the clickable image. I could have functions associated
with the onMouseUp and onMouseDown handlers to set a flag.... as soon as
onMouseDown is called, it sets the flag to 0, then it waits 1 second,
and checks to see if the flag is 0. If onMouseUp has been called, it
will have set the flag to 1, and we call the plain old click handler. If
the flag is still 0, then I know to do the popup/drowpdown menu.

I'm a little worried about the timing between the different flows of
control, though, and I'm also wondering if there's not simply a better
way to do it.

View 1 Replies


ADVERTISEMENT

Activate Hyperlink After Holding Down Mouse For 3 Seconds In An Image Map?

Jul 26, 2010

I have done one project in javascript so far and have had no schooling on the topic, however I have learned quite a lot in the last few months from this thing called the 'internet'. So far I managed to make an html image map that has various tooltips which will appear onmouseover, and the tooltip disappears onmouseout. Each point of coords that i have defined has a hyperlink to a different page on the internet. It works just like i wanted it to and i couldn't be happier, that is, when i'm using a mouse...

When i am using a touchscreen device it is a different story. specifically i'm trying to port my html page to android as i figured it would be easy with the android sdk and webview (it was, but read on). What i found when i used the 'app' on my phone was that onmouseover works when you touch the screen, however it also registers as a click, so pop goes the tooltip, and i'm whisked away to my webpage. not the desired result.

Ideally I would like to hold down the screen for 3 seconds and then the hyperlink would activate, but i decided that just getting the thing functional would suffice for the time beaing so i tried to include some 'ondblclick' that would trigger a document.location. This worked fine on a web browser again, but had no result on the touchscreen. I decided to abandon this half step because I have read that ondblclick doesn't work in an image map and it isn't my intended result anyway.

I have found a lot of javascript and jquery samples that emulate the onHold event that i'm trying to achieve, both on this forum and all over the internet, however these samples are overly complex and are focused on looping an action, such as incrementally increasing a value or zooming or whatever. I just want to redirect the user to another page if they trigger 'onmousedown' for 3 seconds.

View 6 Replies View Related

JQuery :: Holding A Faded In Image After Moving Off Its Trigger

Aug 3, 2011

I have an img#info that I want to fade in when a div#trigger is hovered over. Then I want to be able to move the mouse over to the image and click a hot spot there, without the image disappearing because I moved off of div#trigger.

The code to fade in img#info is simply:

$(document).ready(function() {
$('img#info').css('opacity', 0);
$("div#trigger").hover(
function() {$("img#info").animate({'opacity': 1}, 1000);},
function() {$("img#info").animate({'opacity': 0}, 1000);}
);
});

This works fine as far as fading the image in and out. I tried then adding a hover statement for the img itself, below, but this doesn't work at all. The image is now always on, even though the alerts never fire when I roll on and off the image:

$(document).ready(function() {
$('img#info').css('opacity', 0);
$("div#trigger").hover(
function() {$("img#info").animate({'opacity': 1}, 1000);},

[Code]....

View 2 Replies View Related

Disable Right Mouse Clicking?

Dec 7, 2009

how is it possible to disable right mouse clicking in javascript!?!? my library did it so i know it CAN be done..

View 5 Replies View Related

JQuery :: Possible To Move The Background Of A Site By Clicking And Dragging It With The Mouse?

Feb 22, 2011

I'd like to make it possible to move the background of a site by clicking and dragging it with the mouse. So far I've only found flash solutions and I'd really rather not use flashIf anyone knows of any jquery code that is somewhat similar

View 1 Replies View Related

Mouse Over Code Not Swapping Image On Mouse Over?

Aug 9, 2009

I've got to have a typo somewhere, but i can't seem to find it. I need a new pair of eyes to point it out for me. background: trying to code a mouseover link for a nav bar. everything is working( hyperlink, normal image shows up) but when i mouse over the image swap doesn't happen.

I have 2 parts of code. 1st preloads images and does the swap function. loads in <head> See below:

[Code]...

View 5 Replies View Related

Image Zoom On Mouse Over And Mouse Click Using JS?

Jun 20, 2010

I am in the process of developing a website. I would like to use some images. The image should zoom on mouse over and mouse click i.e the image should zoom to h:100*W:100 on mouse over and on mouse click it should be zoomed to h:1000*w:1000. Also I would like to change the mouse over image and mouse click image before zooming.

View 1 Replies View Related

JQuery :: Advanced Image Transition - Image Fade To Another Oneprogressively While The Mouse Is Over

Oct 25, 2011

The objective is to have an image fade to another one progressivly while the mouse is over, when its not it fades back to the original, whether or not it faded to the target completely or not. That is, if it takes 1 second to fade completely to the other image, and you take your mouse off it at 0.5 seconds, it will begin to fade back to the original. I have a problem where I want to give this ability to multiple images (thumbnails) on a page, without having reams and reams of code and instead just have one function accomadate any number of images.

[Code]...

View 5 Replies View Related

JQuery :: Placing An Image Over Existing Image On A Mouse Click Event?

Mar 12, 2011

I've been trying to have an image be placed during a mouse over or mouse click event. The closest to accomplishing this is having the image be replaced by the image I want to overlay.

View 2 Replies View Related

Keep Track Of Mouse Click On Top Of Image But What When Image Moves?

Feb 27, 2010

I am still designing the website and want some flexibility. I am capturing the mouse clicks fine on top of an image, but the coordinates are absolute and not relative to the image. How can I capture mouse clicks relative to the image so that I can move the image anywhere in my website?

View 3 Replies View Related

On Mouse Over Of Any Image A Pop Up Appears And Displays The Image Information

Aug 24, 2009

[URL] check the above website. on mouse over of any image a pop up appears and displays the image information i want to achieve the same thing in my project which language is used for this purpose and how to do that.

View 4 Replies View Related

Image Fade In From Clicking Another Image

Nov 23, 2010

I've been trying to figure this out for days.. I just found a script that Old Pedant made which is close to what i need: [URL] But two concerns:

1. how can i have it so when i click the thumbnail, it fades in a different image (rather than just a larger version of the thumbnail)?

2. how can i have it fade in and out from simply hovering over the thumbnail (rather than clicking it)?

View 2 Replies View Related

Variable Not Holding Value?

Dec 30, 2010

I am modifying an gallery script called slideSwitch. I want to set the interval value by a variable. For example, If I click button 1 the interval value is 5000 and If I click button 2 - the interval value is 2000 etc. Do I need to pass the value somehow? I My code so far:

Code:
function log(x) {
return x;

[code]....

View 4 Replies View Related

Changing Image Button Image On Mouse Over?

Nov 9, 2009

i want to change the image of image button on mouse over and mouse leave.

View 2 Replies View Related

AddFavorite By Clicking An Image

Jul 23, 2005

I'm using the following to try to create an image that if clicked on, will
throw up the IE add bookmark, but it doesn't work. Can anyone suggest how
to do this?

<a><img src="images/default_static.gif" width="334" height="110" border="0"

y Mooses')"></a>

View 1 Replies View Related

Clicking Image Map Highlights Row

Jul 23, 2005

I have an image map of a subdivision and each section of land in the
subdivision has a lot number on it. Below the image map I have a table
with details about each lot (eg Lot Number, Lot Size, Lot Price
ect...)

I would really like a way so the user can click on the image map and
the corresponding row below the image will be highlighted.

The user clicks on a new row and the previous row goes back to its
original color and the new row is highlighted.

Is the possible? If it is and can someone please point me in the right
direction on how you would do this?

View 10 Replies View Related

Script Clicking On An Image?

Sep 16, 2010

I want to make a script selecting electronics category in this site [URL] A friend told me to use getElementsByClass but I still cant do it.

View 7 Replies View Related

Change Image By Clicking

May 14, 2007

The world map (an image map) that I have shows three continents; namely, America, Asia, and Europe. They are in yellow color. This world map is placed in a HTML file.

Every continent is clickable. By clicking on a continent; say, America, I pop up a window in which some information America is displayed.

And when a continent is active, its color on the map is changed to orange color. Therefore, I have made three more image maps: America is in orange color, Asia is in orange color, and Europe is in orange color.

How do I switch image (i.e. showing the orange color of the continent) after a certain continent is clicked by users?

View 7 Replies View Related

Variable Not Holding It's Value, Document.getElementById?

Nov 24, 2010

I seem to be having trouble with my string variable in innerHTML.. here's my code:

function header() { // Navigation Bar
110 var o = document.getElementById("header");
111 var s = '<h3 style="float:left;">'

[code].....

View 3 Replies View Related

Hiding A Div (picture) And Still Holding Its Position?

Feb 4, 2011

I'm currently trying to hide my navigation button when it hides the end of the list, right now I currently have:

Previous / Next (they are about the same anyways)
function previousEvent(i) {
var k = new Number(i);

[code].....

View 2 Replies View Related

JQuery :: Dialog After Clicking On Image?

Aug 20, 2009

I Have an image and onlick dialog appears

$('#.myImg').dialog();

It works fine but when I close the dialog and click on the image again nothing happens.

View 6 Replies View Related

JQuery :: Expand A Row When Clicking Only On An Image

Jul 31, 2010

I'm testing the Jexpand plugin (expand table rows): [URL] and i would like to know what i have to modify to expand/collpase rows only when i click on the left arrows picture (not by clicking everywhere on the row)?

[Code]...

View 7 Replies View Related

Drop-down Menu On Clicking An Image?

Dec 5, 2010

I need a drop down menu to appear when I left-click an image.... have tried a lot but failed...

View 9 Replies View Related

Executing Alert After Clicking Image

Feb 4, 2009

When I click on my image, I am supposed to get it to execute the function initRedirect().

However, it says image01 is equal to null in the error console.

This is the line that does not work!

View 4 Replies View Related

Disable Image Link After Clicking

Aug 17, 2005

i've searched this forum before posting but didn't find a "clean" solution to my problem.
I have an image with a link on it:

Code:

<a href="#null" onClick="addValue('bold');"><img src="images/myimage.gif" title="Some text" alt="Some text" /></a>
which adds the value in a textarea in the same page via this function:

Code:

function addValue( val ) {

var tb = document.forms['valuesform'].elements['valuesfield'];

if ( tb.value.length > 0 ) tb.value += " , ";

tb.value += val;
}

I need to disable the link after the image has been clicked,preventing multiple insertions of the same value. I've modified the link this way:

Code:

<a href="#null" onClick="addValue('bold'); this.onclick=null;" ><img ......
but while only one click is allowed,i get many JS errors in the JSConsole like

Code:

uncaught exception etc.... and i think this is not a good sign.=

View 4 Replies View Related

How To Call Function Alone On Clicking Image

Mar 23, 2009

Code:
<div id="div1" onclick="function1()">
<img src="image1.jpg />
<div id="div2" onclick="function2()">
<img src="image2.jpg />
</div>
</div>
When I click image1, function1 is called.. but when I click image2, function2 is called first, then function1 is called..I want to call function2 alone when i click image2..

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved