Problems With Objects, Argument.caller And SetTimeout
Jul 23, 2005
the structure of my source code is like this:
<script>
C = function(){
//some initialization
}
C.prototype.start = function{
//some action
setTimeout(arguments.caller.callee, "200");
}
var obj = new C();
obj.start();
</script>
This should execute the method start every 200 milisec, but (in some cases) it gives me an error because arguments.caller is null. Is there a "direct" method to use setTimeout without this arguments? stuff?
BTW: I'm working with IE Version >= 5.0
Is there a better solution to get start work?
View 5 Replies
ADVERTISEMENT
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
Nov 30, 2006
how to you use the result of a function as the argument for another function instead of passing the actual function to it. i.e.
function foo2(){}
function foo(func){}
foo(foo2);
This passes foo2 to foo, can I do foo(foo2()) ? i.e. is the difference between whether a function is passed or evaluated dependent on whether you use "()" after the function name?
View 1 Replies
View Related
Oct 11, 2006
I'm trying to write an 'each' function for a JavaScript array that
behaves like Ruby's Array#each. (It doesn't matter if you know Ruby to
help with this question.)
My problem is the scope of 'this' inside the iterator callback. I would
like it to be the same as the object that called the each() on the
array. Right now I have to do that with a closure or an
explicitly-passed 'this' scope. For example:
function Person( inName, inCats ) {
this.name = inName;
this.cats = inCats;
}
// Using a closure
Person.prototype.showInfo = function( ) {
var me = this;
this.cats.each( function( catName ){
alert( me.name + " owns " + catName );
} );
}
Array.prototype.each = function( inCallback ){
for ( var i=0,len=this.length; i<len; ++i ){
inCallback( this[ i ], i );
}
}
phrogz = new Person( 'Gavin', [ 'Fuzzles', 'Kitty' ] );
phrogz.showInfo( );
--Gavin owns Fuzzles
--Gavin owns Kitty
// Using an explicit scope
Person.prototype.showInfo = function( ) {
this.cats.each( this, function( catName ){
alert( this.name + " owns " + catName );
} );
}
Array.prototype.each = function( inScope, inCallback ){
for ( var i=0,len=this.length; i<len; ++i ){
inCallback.call( inScope, this[ i ], i );
}
}
Inside the each() function, arguments.callee.caller would give me a
reference to the showInfo function object. What I am looking for is a
way to access the scope of the 'this' receiver within that particular
invocation of showInfo(), so that I can use it in place of inScope
without having to pass 'this' each call.
View 9 Replies
View Related
Oct 19, 2006
is there a way to get the name of the calling object of a method?
function MyFunction()
{
this.SayCallersName = _SayCallersName;
}
function _SayCallersName()
{
alert("how to get 'oTest' as output here?");
}
var oTest = new MyFunction();
oTest.SayCallersName();
What I want as an output is the name of the object I have created
without passing it to the constructor.
So I do not want oTest = new MyFunction("oTest") or something like
that. Is this possible in JScript?
View 1 Replies
View Related
Oct 21, 2009
I am trying to take code that I have and change it to be called from an XML file.
Right now I have random quote and random author arrays stored in an external .js file. And then a function to make everything random. Then I have it called and modified using the innerhtml method. All of this works fine and I will be including that code.
Now I want to modify this and change it to where I can store my quotes and my quote authors in an xml file. Then called through the JS. (more info under this code)
[Code]...
View 3 Replies
View Related
Mar 10, 2011
I have to print my cell phone call records but unfortunately my wireless provider displays the number I called only when mouse is hovered over Call details. I have 470 call records and copy pasting all those numbers when mouse is hovered over it will be one hell of a task. Is there any way I could save all the information related to Called Number and do not have to move my mouse for each and every number? Using my basic programming understanding.
(Though I know nothing about javascript), they are using some mouseover function that displays this information. The possibility of this information to be on the server is less because this information is even available when I switch off my wireless. I can paste that portion of the code. Saving this website using normal "Save as" does not save the required information. Is there any other way I can save this website will all its details or somehow disabling this mouseover function so that call details are not hidden anymore.
View 10 Replies
View Related
Mar 3, 2011
I'm new to jQuery and Javascript overall, I have searched the internet to make use of jQuery instead of the HTML's iframe tag. My problem is links inside a .load file, I want them to refresh the box on the index.php file, not the file itself (in this case the links are in blog.php)
Here's everything I can provide with:
Files:
"index.php"
"blog.php"
In my index.php file I have this script to make my index.php links open the required file in my div box.
"index.php"
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#html").load("blog.php"); // shows the blog.php when I first enter index.php, which I want to have
$(".link_click").click(function(){
$("#html").load($(this).attr("id"));
});
});
</script>
Here's "index.php" link:
<a class="link_click" id="blog.php">Blog</a>
Here's my div box in "index.php" where I show the information within the loaded file:
<div id="html"></div>
All this works, but here's my problem, I have multiple links within "blog.php" which I want to make "index.php" to refresh the "index.php"'s html div. Is there some kind of way to edit the "blog.php"'s script to make it "index.php" the parent or reference?
"blog.php"
<script type="text/javascript">
$(document).ready(function(){
$(".link_click").click(function(){
$("#html").load($(this).attr("id"));
// Need to change this(?) to make it reference the index.php's html div box
});
});
</script>
View 2 Replies
View Related
Apr 17, 2011
Is there a way in Javascript or Jquery to return an array of all objects underneath a certain point, ie. the mouse position. Basically, I have a series of images which link to various web pages but I have a large semi transparent image positioned over the top of the other images. I want to find the href of the background image that the mouse pointer clicks over.
View 1 Replies
View Related
Sep 5, 2009
Is there a better way to extend object with internal objects?
$.fn.bestShow = function(s) {
var d = {
width: 0,
height: 0,
order: "numeric",
orderBy: "",
[Code]...
View 3 Replies
View Related
Jul 12, 2010
I have the following function that's supposed to say "Please make a guess" 20 seconds after an initial confirmation is displayed. However, it's immediately displayed as soon as someone hits "Cancel". If I change it's time to 40000 (20 seconds after the initial function is called), it does do it 40 seconds total, so it kind of does what I want. So it seems that the second setTimeout is initiated from the time the script is called generally, but I'm looking for a way specifically to have the 20 seconds start only after the "cancel" button is hit.
[code]...
View 1 Replies
View Related
Jul 23, 2005
I stumbled over a strange behaviour of Mozilla. When I want to access the
caller property of a function that was not called from within another
function, Mozilla seems to abort the script. No error message, no hang, just
stopping script execution at that point. Why? And what is the remedy?
View 4 Replies
View Related
Jun 28, 2010
i call a javascript function when click on a href (for hiostorical reasons) and pass this as a parameter.
[Code]...
View 4 Replies
View Related
Aug 8, 2006
Does anyone have any coding rules they follow when doing argument checking?
When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
View 4 Replies
View Related
Jul 23, 2005
If I try to append a PARAM tag twice I'm having problems:
var.medDiv = document.getElementById("myDiv");
var medObj = document.createElement("object");
var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);
p = document.createElement("param");
p.setAttribute("AutoStart","false");
medObj.appendChild(p); // <-- this one
medDiv.appendChild(medObj);
The line with the "this one" comment triggers IE to tell me that it has
an invalid argument. If I change the order of the PARAMs then the new
second PARAM will give me the error. If I move the setAttribute to after
the appendChild I still get the error.
View 7 Replies
View Related
Jul 20, 2005
Suppose I have a frame like 123bottom.html and within it, I want to promt
the user for a response (in the <HEAD>) like
var ans = prompt("What is your name?");
and then reload the page (via, say window.location.reload() ?)
using the argument of the value of ans appended onto the url so that, in
effect, say, I am calling the new frame as
123bottom.html?ans=Ike
Can someone show me how I need to call the page again, itself, like this
once I have the value for ans? Thanks, Ike (himself)
View 3 Replies
View Related
Apr 26, 2010
Quite often, I define variables like so:
Code:
var something = (function () {
if (x) {
[code]....
View 1 Replies
View Related
Jan 26, 2005
Can you pass an array reference to a constructor? I don't know if it's because the syntax is screwy or it's impossible, but the following doesn't work.
// row constructor with array called fields
function RowObject(fields)
{
this.fields=new Array();
this.fields=fields;
}
row=new RowObject(fields);
alert(row.fields[0])
View 6 Replies
View Related
Mar 14, 2002
How do you pass an argument to a function.
for example if you have a <span id = "test" onMouseOver ="myfunc(x)>
eg you have lots of differant span id's but you want then all to have a certain background-color with each individual on mouseover event without having to write separate code for each span id
eg <span id=" test2"onmouseover ="this.style.background ='red'>....
View 1 Replies
View Related
Jun 9, 2007
How can I modify any one of these global variable identified via a function
argument?
var x1 = "bla";
var x2 = "bla";
var x3 = "bla";
function modify(variable) {
???? [variable]???? = "blabla":
}
The following onclick should change the string value of variable 'x1' from
"bla" to "blabla", via the above modify() function.
<a ... onclick="modify('x1')">
View 8 Replies
View Related
May 21, 2010
I amreceivingthe following error on IE8:Invalid argument. jquery-1.4.2.js, line 5899 character 5 Now I have used the debugger, and this seems to be the only error it catches. And I realize that I could go through each line of what I wrote and figure out what line triggered this portion of jQuery. However in the interest of making jQuery better, I want to understand this error and fix it in the jQuery file.
[Code]...
View 4 Replies
View Related
Jun 23, 2009
I have used an object in the past as a function argument, but this was for a plugin that I wrote. Using it in the architecture of a plugin it worked. BUT, this time, I just want to write a normal function, but still use an object to set defaults and pass in changes to those defaults through as a param. Is this possible, or do I have to make this a jQuery function like $.myfunction() ?
[Code]...
View 5 Replies
View Related
Mar 12, 2009
I'm trying to pass an array as an argument for a function on load of an html page, but can't seem to get it to work. Here is my code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
[code]....
View 2 Replies
View Related
Apr 8, 2010
i have an initAll() called on window.onload within initAll() I assign a few onclick handlers to some links. However, it would be great if I could pass an argument to the handler, so I could use the same handler every time... but if I include two brackets for each handler, it executes immediately... ignoring the 'onclick' bit...
window.onload = initAll;
function initAll(){
document.getElementById('btn_events').onclick = getSpecificFeed('events');
}
[code]....
View 2 Replies
View Related
Aug 21, 2011
This is a post relate to this post:DOM inside variable with innerHTML?To reduce any ambiguity this new thread deals with the code below.The previous post was more about how DOM can be used in a variable.This one has to do with a similar problem, but more with functions.
<html>
<head>
<title>Test</title>
[code]....
View 4 Replies
View Related
Mar 19, 2010
I've been trying to show a div using jQuery's show function with the scale effect. My code works fine in Firefox. When I test it in IE7, it breaks. I narrowed it down to either the origin argument of the scale effect, or the time argument of the show function (which seems unlikely). Like this:
Works in IE7, italics added to show commented code better:
Code:
$(document).ready(function() {
$("#hover").hover(
function() {$("#content_show").show("scale",{percent: 100, direction: 'vertical'});},//, origin: ['center','center']},500);},
[Code]....
Also, not as important, but what is the syntax of the origin property? What values can I use in it?
View 2 Replies
View Related