Simple Animation - SetTimeout Function And Paint Method
Dec 24, 2009
I'm trying to graph line with a delay between each line drawn - my code is:
var jg = new jsGraphics('Canvas');
jg.setColor('maroon');
jg.drawLine(40,130,80,120);
setTimeout('jg.paint()',10000);
jg.drawLine(80,120,120,110);
setTimeout('jg.paint()',10000);
Unfortunately it draws all the lines at the same time i.e the setTimeout function doesn't like the paint method.
View 1 Replies
ADVERTISEMENT
Dec 15, 2010
I'm new to JavaScript, and have been playing around with a few simple functions to get going. However, I've hit a problem that I just can't fix, I'm trying to write a simple function to animate the collapse of a div using setTimeout (I know, jQuery does it a lot better), and it's gotten the best of me. The only error it's giving me now is
Code: missing ; before statement on line 25 but I can't see why. I assume it's something to do with my abuse of the setTimeout syntax (why does it insist that everthing is enclosed in quotes.I'm sure there are much better scripts than mine, and searching the forum I've come across Vic Phillips' fine specimen which mostly went over my head. But if I just wanted it to work I'd use jQuery - I'm more interested in why it's not working.
code is below. In addition to this I've also got an external script to compensate for browsers without getElementsByClass, but it should work in modern browsers up to the point where it doesn't!
[Code]...
View 4 Replies
View Related
Apr 4, 2010
What I want to do is have 5 <div>s displayed in a fixed position on my page. The divs will contain text and pictures. Only one div is displayed at a time, and every 5 seconds, the next div slides over the top of the current div (from right to left) until it is completely obscured. At the conclusion of the fifth, it starts again with number 1.
View 5 Replies
View Related
Oct 1, 2009
I am trying to write code to print a message 5 seconds after document has loaded.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script>
[Code]....
The message appears ok but the page loading bar in the browser + hourglass wont go away (in firefox).
View 1 Replies
View Related
Mar 28, 2006
What I want is an element with a shifting background image:
<html><head>
<script type="text/javascript">
var x = 0
var y = 0
inc = 4
function bgWander(el){
x = x + Math.round(2*inc*Math.random())-inc
y = y + Math.round(2*inc*Math.random())-inc
el.style.backgroundPosition = x + 'px ' + y + 'px'
setTimeout('bgWander(el)',200)
}
</script></head><body>
<a onLoad="bgWander(this)" href=""
style="background:url(images/bgbar.png)">Link</a>
</body></html>
Can you show me the error of my ways?
View 3 Replies
View Related
Oct 6, 2010
I'm sort of lost on this one. I've looked at many different examples and tried manyombinations but I still can't get this to work. Here's the code without the setTimeout:
$(seq).each(function(index, value){
var divID = "#div-" + value;
$(divID).animate({
[code]....
View 2 Replies
View Related
Aug 2, 2010
I am a newbie in programming...recently I have developed a very simple (probably too simple!!!) javascript code that trims strings and shows animation....the code should be self explanatory....and i have included comments in the snippet so everyone understands what I did....just save the txt file as .html and double click to see the output in browser...
View 2 Replies
View Related
Jul 23, 2005
I need to capture signature in HTML from site visited from a PDA...
I was thinking if is it possible to have a region where I can 'write'
the signature and send via post coords of points selected in signature area.
View 1 Replies
View Related
Mar 30, 2010
This is meant to be a very simple animation. Everything seems to be correct, but it doesn't seem to run. Basically it is a system where the image is 50px taller than the box it is being displayed in. When you hover over the image, the image is meant to move up via jquery to show the bottom (previously hidden) 50px and cut off the top 50px.
Here is my Site: [URL]
Here is my HTML:
Code:
<div id="container"><div>
<a class="none" href="<?php the_permalink() ?>"><img src="/themes/smo/portfolio/<?php echo get_post_meta($post->ID, 'portfolio_img',true).".gif"; ?>" alt="" /></a>
</div></div>
Here is the Jquery:
Code:
$(function(){
$("div.container div a").hover(function(){
$("img", this).stop().animate({top:"-51px"},{queue:false,duration:200});
}, function() {
$("img", this).stop().animate({top:"0px"},{queue:false,duration:200});
});
I think its something to do with the container class.
View 4 Replies
View Related
Sep 19, 2011
I would like to call method when all my animationsare finished. What I do wrong? My callback function has been executed before animation start
var elems = new Array();
for(var i = 0; i < 4; i++) {
.push($(elemContainer).children(':eq(' + i + ')'));
[code]....
View 1 Replies
View Related
Dec 12, 2010
Looking for a simple method to Toggle textbox yes/no using CheckBox
This example does not work!
What I am trying to do:
View 2 Replies
View Related
Sep 11, 2010
I'm pretty new to jQuery so try and go easy. Trying to do a simple AJAX POST using the jQuery post method and it doesn't seem to be working.
Heres my code:
$.post("sub-account-ajax.php", { email_address: "test@test.com" },
function(data){
alert("Data Loaded: " + data);
});
Heres the code for sub-account-ajax.php:
<?php
if (isset($_POST['email_address'])){
echo 'youre set';
}else{
echo 'nothing set';
}?>
When this code is executed I do not get any alerts or any error messages whatsoever. I've been pretty good with figuring things out so far with jQuery, but this is the first I'm stumped with.
View 2 Replies
View Related
Oct 25, 2011
I've noticed that setTimeout seems to return a simple integer as it's "id" which can be used to clear the timeout ahead of time. So, in order to have multiple setTimeouts called (which requires the previous one to be cleared before the next one is called), I simply did this:
clearTimeout(setTimeout(function() {
/* some code */
}, 1000) -1);
Note the "-1"... each time this code is called, it starts a new setTimeout and clears "instance-1" which is supposed to be the previous instance. The idea is that this block can be called hundreds of times, and when the calling finally stops, the inner code is executed 1 second later. This SEEMS to be working (yes, even in MSIE!). Question is, am I fooling myself? Is this wrong?
View 4 Replies
View Related
Sep 28, 2010
I am having a little trouble with the "src" attribute method.
I am trying to use a click event to play a specific movie using the following:
A link to an example (the link is at the bottom):[url]
View 1 Replies
View Related
May 10, 2006
I want to change the elements class name dynamically when mouse is out with respect to that element.I want to change the class name after some delay (i.e, i am using settimeout function).
var ulNodes = getElementsByClass("nice-menu");
var liNodes = null;
for(var i = 0; i < ulNodes.length; i++) {
liNodes = ulNodes[i].getElementsByTagName("li");
for(j = 0; j < liNodes.length; j++) {
if(liNodes[j].className == "menuparent") {
liNodes[j].onmouseout=function(){
timer = window.setTimeout(function (){
this.className = "menuparent"; //My problem is with //this line
},4000);
} } } }
I need to set the elemets class name to "menuparent" after some delay after the pointer moves away form that element.
-> When ever i say alert(this.className); in the setTimeout function, the alert box says undefined.
-> I can succesfully alert any where else in the mouseout function except within the settimeout function in mouseover function of that element.
View 1 Replies
View Related
Sep 13, 2011
I want to design a page flashes 4 digits when loaded, press submit to stop, and starts when press again.Below is the script:
Code:
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
[code]....
View 1 Replies
View Related
Oct 10, 2006
I'm not exactly sure why this doesn't work. I'm basically just trying a
simple approach at a slide down div.
function slide_div {
setTimeout("document.getElementById('mydiv').style.length=ཆp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཐp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཚp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ཤp x'",1000);
setTimeout("document.getElementById('mydiv').style.length=p x'",1000);
setTimeout("document.getElementById('mydiv').style.length=ླྀp x'",1000);
}
It seems like it just runs the last setTimeout line and pops out all at
once. I've even tried adding a=, b=, c=,. etc at the begining of each
line to no avail.
View 6 Replies
View Related
Mar 7, 2011
How can I have a function parameter in a function?
Something lke setTimeout();
setTimeout(function() {
how can I do it like this?
[code]....
View 4 Replies
View Related
Jul 30, 2009
does anyone know if the setTimeout() function in js has been just recently supported? i created an online demonstration of a product that uses this function to delay the playing of .wav files after various second intervals. i know that Opera doesn't support this function because when I click my button, all of the .wav files that i have in the function that runs behind the button play at once. i have probably 10 wav files that are played throughout the function, at various conditional statements. does anyone know if earlier (like REALLY old) versions of IE do not support this function? or maybe ie8 doesn't support it? i developed this and tested it in all major browsers except IE8 and any version earlier than IE6.
View 5 Replies
View Related
Jun 6, 2009
I did search the forums but couldn't seem to find anything on this specifically. I basically need to pass a key event and a 'name' to nameCheck() after 3 seconds. This works fine in Firefox but Internet Explorer gives the error: Member not found. I'm more of a PHP guy than a JS one
<input type="text" onkeyup="nameCheckTimer(this.value, event)" value="" />
function nameCheckTimer(name, evt) {
setTimeout(function(){return nameCheck(name,evt)}, 3000);
}
function nameCheck(name, evt) {
//need name and the key event to be available here. I have code to handle the key codes which works fine
}
View 6 Replies
View Related
Jan 16, 2010
I am trying to use the window.setTimeout feature so that a message pop-up with yes/no appears on the screen asking whether to extend the session.*If yes is clicked, the current page reloads.*If no is clicked, nothing happens. (the session will expire anyway).
View 5 Replies
View Related
Feb 22, 2011
I have written the following code (quite meaningless. Just to check why setTimeout is not working in a similar real-life code) to enable the user to input a given time interval (hh:mm:ss) when a p is clicked, and then alerting the user with the time entered in the seconds portion one second after the div is clicked. But it is not working. I think the setTimeout is the culprit, the way I am passing parameters to the function inside it, but don't know where exactly am I erring.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
[Code]....
View 3 Replies
View Related
Oct 31, 2010
I have a button that when you click it displays the results of my db in a div. What I am trying to do is to get the results to update every five seconds.
I thought setTimeout was the best way to achieve this. However I am getting the error message that ID is not defined on the setTimeout line. I thought it would automatically input ID into the fields marked ID when the onloadXMLDocRefres ('File.php','txtHint') button is clicked?
The button works to load the script, but the refreshing the div is not.code...
View 4 Replies
View Related
Feb 2, 2011
I wanted to write my own script for a fade-in animation, since the ones I have found have got too many options or need some framework, which makes them unnecessarily big. I wanted to learn too.Unfortunately, the code didn't work as I wanted, and I commented some things so as to find out what's happening.Why is an object reference assigned to what was previously a string?
View 6 Replies
View Related
Jun 24, 2006
I keep getting the function first as being undefined for some reason I
don't get.
I'm trying to use setTimeout() to pause execution so that an image in
my web page is switched every two seconds for another. Code:
View 1 Replies
View Related
Aug 3, 2011
I am using both these functions for the purpose of slider.But when you leave the tab & come again. The slider moves so fast.
Looks like it clears the interval automatically.
View 3 Replies
View Related