Executing Function On Click & Hold And Regexp

Apr 22, 2007

What is the best way to execute a function when the user clicks and holds an element for, say, 3 seconds? A Google search didn't reveal anything, but I couldn't really come up with a concise search query either. The only way I can think of is setting a timeout onclick, and clearing it onmouseup. Is this the best method?

On a somewhat related note, I am trying to check if the user has entered a valid time, in the form (m)m:ss, where the first m is optional. I decided to use a regular expression. (Is that the best way?) So far I have come up with [0-5][0-9]:[0-5][0-9], however, this allows other characters at the beginning or end of the string, as well as forcing the first character. If I change the first character to [0-5]?, it makes the first character optional but it allows times that don't meet that requirement - which basically defeats the purpose of having that rule at all.

View 1 Replies


ADVERTISEMENT

JQuery :: Implementing A Click And Hold Function?

Jun 19, 2010

I have a grid of items that when clicked lead to a new page. I would like to implement a function so that if a user clicks on an item and holds for at least 1000ms, a menu will be shown next to the item and they will not be taken to the next page.

However, all of my current attempts either lead to the menu not being shown, or it is shown and the user is redirected to the next page anyways.

Here's my current code:

jQuery(document).ready(function(){
var mousehold;
jQuery('.item').mousedown(function(){

[Code].....

View 4 Replies View Related

Timer Stops When Click-and-hold Browser Close / Fix It?

Oct 23, 2009

We have a testing application that displays a timer on the screen using Javascript. It seems to be working very well. However, someone brought to my attention today that if you click-and-hold the browsers close button in the upper right corner (the X button in Windows) that the timer will stop. You can then slide your mouse cursor off of the button, and the browser will not close, but the timer was stopped for the entire time that the button was being held down. This also works for the Minimize and Maximize buttons.

View 7 Replies View Related

Display Div On Different Z-index, When User Click And Hold The Mouse?

Jan 17, 2009

I would like to display a div on a different z-index, when user click and hold the mouse.

1. how can i do that ?

this step should be the base, for my next question. while holding button clicked and moving mouse, i would like to move also (with the same amount of pixels) the div (previously mentioned)

2. how can i detect how many pixel (and in which directions / axes) the mouse moved ?

View 1 Replies View Related

Diving Into Regexp By Porting A Perl Script Over To Js That Uses Regexp To Compress Into A Bookmarklet Capable Format?

Aug 10, 2010

I'm finally diving into regexp by porting a perl script over to js that uses regexp to compress javascript into a bookmarklet capable format.I've successfully worked out 90% of the expressions but am troubled with a few, this one at the moment is odd:I want to remove the first line if it hasjavascript:So I thought str.replace(/^javascripts+:s+/, "") would be ok. I want javascript text, any space, colon, any space and new line. what I'm doing wrong.btw this is the original perl version

$src =~ s{^// ?javascript.+:.+
}{};

View 3 Replies View Related

How Can We Stop IE From Executing Javascript On A Back Button Click

Nov 14, 2007

Basically, I have a page that I load with 10 input fields. If users
have JS enabled I want to hide 5 of these fields so as to reduce
clutter. If the user needs these extra fields an "Add" button can be
used to display the hidden fields one by one.

Once the fields a filled in the user submits them for validation and
if there are any error They can "Go back" to make some changes. The
whole process works great in FF & Opera but IE lets me down because if
you use the Browser "Back" button the Javavscript gets executed even
though it should be loaded out of cache.

View 3 Replies View Related

Regexp Test Function Behavior

Oct 29, 2006

I coudn't understand some behavior of RegExp.test function.

Example html code:
----------------
<html><head></head><body><script type="text/javascript">
var r = /^https?:///g;
document.write( [
r.test('http://a'),
r.test('http://b'),
r.test('http://c'),
r.test('http://d')
]);
</script></body></html>
---------------------

The page displays true, false, true, false. (in Opera, Firefox and IE)
This is strange because I expected it would display true, true, true,
true. There must be something I didn't know about the function
RegExp.test.

View 11 Replies View Related

Keyword SEARCH Function With REPLACE(RegExp)

Jun 10, 2009

is it possible to combine the the following functions with each other in an array for example and if so, would someone be kind enough to show me how. the reasons are 1. to see if it is at all possible and 2. to learn so that I can combine further possibilities in the future. the first script compares user keywords from search mashines and the second replaces certain strings/paterns with others.

[Code]...

View 9 Replies View Related

RegExp.input, RegExp.leftContext, ...

Jan 19, 2007

I found this in felgall's page. I added script tag

<script type="text/javascript">

var re = /(t)he/g;
var mystring = "Over the moon.";
re.text(mystring);
alert(RegExp.input); // or RegExp.$_
alert(RegExp.leftContext); // or RegExp["$`"]
alert(RegExp.rightContext); // or RegExp["$'"]
alert(RegExp.lastMatch); // or RegExp["$&"]
alert(RegExp.lastParen); // or RegExp["$+"]
alert(re.source);

</script>

I don't see message box. Please tell me what I can do.

View 3 Replies View Related

Executing Function

Dec 16, 2003

I need to execute a javascript function on a page on a site. The link of a button is javascript:executefunction(2). However, I need to execute the function javascript:executefunction(1). Is there a way to do this by typing it into the internet explorer address bar (like the view-source:address thing)? Or is there a program that can accomplish this? I need to do this to test how it would execute the command differently. I have no access to the server (it is not my server/site) and don't have to option of download all the files to my computer (too many external css and js files).

View 3 Replies View Related

Self Executing Function?

Feb 26, 2010

Can somebody explain the following code:

var dbg =
(
function(){

[code]....

View 5 Replies View Related

Function Only Executing Once?

Jul 5, 2010

i've been trying to make an animated fly/slide-out menu and am just trying to get the basic mechanics down. long story short i'm just starting with a simple mouseover/out setup to get things going.currently (as seen in the code below) i have a div which should simply move down 30px from its starting point on mouseover and return to its starting point on mouseout. this works perfectly the first time the mouse enters and leaves the div but nothing happens the next time the mouse enters the div unless the page is refreshed.

Code:
<html>
<head>

[code]....

View 1 Replies View Related

Function Not Executing When Called?

Nov 15, 2011

I'm trying to run this script on Firefox. I'm copying and pasting the whole thing in here just to be safe, but I'm mostly concerned with getting the findLegendary function to call catchPok(). The script executes fine, goes into the battle, but then...does nothing.It runs the catchPok function if I manually click and deselect the "Find Legendary" window option, so alternately, if somebody knows how to make the program automatically click the element at that point to stop repeating the function (maybe?) and it works, I'd be just as happy with that. My best guess is that the autoContinue function might be interfering somehow, since it runs that portion of the code with the manual findLegendary shutoff, but to be honest I'm pretty clueless.

What I want it to do is run the catch function through, catch the game pixel, and then go back to repeating. I don't care how this is accomplished as long as it can feasibly loop. The game rules allow botting, so this isn't against any site rules, either.

// ==UserScript==
// @name Pokemon Vortex Tool
// @namespace vortexrising.tk

[code]....

View 2 Replies View Related

Executing Function After REDIRECTING To URL?

Sep 7, 2010

Following is my problem def: Load a HTML page and set the form fields on that page and submit it using javascript. I tried following code: I wrote a html file with following code in it.

<html>
<head>
<title>Test</title>

[code]....

View 1 Replies View Related

Executing A Function From String Text

Jul 23, 2005

I have an application that navigates through the links in a document,
most of which are "javascript:doThisFunction(args)" type of links.
Using DOM navigation I can find the reference to the javascript
function and store it as a String variable, but is there a way to
execute the function? Currently the only way I know how to do it is
in a series of if/else statements as in:

if (link=="doThisFunction(args)")
doThisFunction(args);
else if (link=="doThatFunction(moreArgs)")
doThatFunction(moreArgs);
... etc.

is there a more elegant way to do this?

View 2 Replies View Related

Prevent A Javascript Function From Executing Twice

Jul 23, 2005

I have a select dropdown and 5 text fields. based on the option
selected (which are the units - cm/mm/inches/ft/yard etc), i change
the values in the text fields using javascript to the corresponding
units.

my problem is that when the options are selected very quickly(for eg
using the keyboard's up/down keys) then quickly, the text field values
lose their connection with the select box and the values become
illegal.

I suspect that the javascript function is being called even before the
earlier execution has not terminated. I tried using a global variable and using it as a lock, but still no success.

View 1 Replies View Related

JQuery :: .onclick - Executing A Function Before Another?

May 17, 2009

Need the closeAll() function to execute before the div's slidedown.All divs are initially hidden, just making a check that if one isopen, it must close before any new div runs.Can someone help point me in the right direction?Here is what I have so far.

function closeAll() {
$(".div1").slideUp('slow');
$(".div2").slideUp('slow');

[code].....

View 1 Replies View Related

Hidden DIV - OnClick Function Not Executing

Nov 29, 2011

I have a hidden div containing a table. When the user enters a number into a text field and presses submit, the div containing the table appears. That's what is suppose to happen anyway. I am using an onclick function within the submit button to change the css display from none to block. The javascript is not executing.

Code:
How many devices do you want to register?
<input type="text" name="rows" id="rows" size="2" >
<input type="submit" name="submit" value="Enter" onclick="showRows();">

The javascript is
Code:
function showRows() {
var numRows = parseInt(document.getElementById('rows').innerHTML);
if(numRows != "") {
document.getElementById('Table').style.display = 'block';
} else {
document.getElementById('Table').style.display = 'none';
}}
Am I going about this the right way?

View 1 Replies View Related

OnClick Function (Yes / No List) Not Executing?

May 4, 2011

I have this line in my code:
echo '<a href="" onClick="yesnolist()">Free Chat</a>';

Then at the top I have:
<? php
//have some php here
?>
<div class="innerContainer">
<head>
<script type="text/JavaScript">
function yesnolist(val) {
alert("lakjsd");
var e = confirm('Do you want to send a free chat request?');
if (e == true){
window.location.href = "[URL]";
window.location [URL];
return true;
}else
return false;
}
</script>
</head>
<span class="headings2">CONTACTS</span>
//and more code after this
echo '<a href="" onClick="yesnolist()">Free Chat</a>';
Why is it not doing my onClick()?

View 15 Replies View Related

Executing Predefined Function Via OnClick

Aug 3, 2011

I'm an experienced programmer (c, perl , python, bash) but absolutely newcomer with Javascript. The code I'm experimenting with is shown below. What I'm trying to do at this point is define a function in a script section in the head of my html page, then call that function in the onclick action of a form button. Sounds trivially simple, but for some reason it isn't doing what I expect. The eventual result will be that the Javascript will launch a Silverlight video player using the values supplied by the end user, but for now I just want to get the basic buttons to work.

<code>
<html>
<head>
<title>Silverlight player</title>
<script type="text/javascript">
var vProto;
var vServer;
var vStream;

function showMe() {
alert("In the function");
vProto = document.getElementById('proto').value;
vServer = document.getElementById('server').value;
vStream = document.getElementById('stream').value;
return false;
}

function alertMe() {
alert(document.getElementById('server').value);
return false;
} .....

View 1 Replies View Related

Function To Stop Executing Script

Mar 30, 2009

Is there a function in javascript the same as PHP's exit(). I have:
<script>
****EXIT OR EQUIVILENT IN JAVASCRIPT*****
</script>
<a id="java" style="color:#FFFFFF; ">Enable javascript to view my website</a>
This tells me if javascript is on or off.

View 1 Replies View Related

JQuery :: Function Executing But Not At The Right Time

Aug 30, 2010

I've been having trouble with a seemingly simple function...I have a form where 3 of 5 field values are generated by a script tied in with Google Search (like a business address). The user is prompted to enter their business license #, and as soon as the input field has val().length == 9 characters, I want to execute an ajax call among some other functions... The problem is the function works when there are 9 characters in the field, but only after I generate a new and different set of values for the generated fields (i.e. the first generated values, coupled with those 9 characters isn't enough to set off the function, although when i use a second set of generated values, the function kicks in). Here's the applicable code...although there's a lot more to the picture...

[Code]....

View 1 Replies View Related

Executing A Function On Page Load ?

Oct 28, 2010

Test Page: http:[url].........

Code below:

<script language="JavaScript">
function function1(){
window.scrollTo(0,265);[code].....

Question: Is it possible to get rid of the button and have it scroll to 0,265 on page load ?

Comment: <body onload="function1();"> doesn't appear to work.

View 1 Replies View Related

Executing Function Based On Given Condition

May 21, 2011

I would like to execute functions based on the value of a form. This is the code I have.
<input type="text" id="posttitle" value="Title" onblur="if(this.value.length == 0) this.value='Title';" onfocus="if(this.value == 'Title') this.value='';">
Now let's say I want to execute the function "myFunction()" onblur if that same condition is met, so not only will it recreate the value "Title" but it will also execute a function afterwards. How can I achieve this? I assumed I'd do something like...
onblur="if(this.value.length == 0) this.value='Title' myFunction();"
But that did not work.

View 3 Replies View Related

Executing Function Stored Within Object

Oct 20, 2011

I have a strange issue currently within my event.state I have a function that I would like to execute. So you can say that event.state = function(). How I now execute this function that is stored in event.state?

View 2 Replies View Related

Function Call In Firefox In OnLoad Not Executing

Jul 23, 2005

I made a function call on the form onLoad event and it is ignored
in firefox. I place an alert box just b4 the fucntion and it is called
correctly by the browser but it stops when it enters the fucntion.
This work as it is intended in IE. How do I make a fucntion call in
Firefox?

View 2 Replies View Related







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