Get The Name Of The Caller Object As String?

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


ADVERTISEMENT

JQuery :: Links Within Load Object Needs To Reference Parent / Caller

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

Getting The 'this' Scope Of The Caller

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

Change JS Random Quote To XML Caller?

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

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 View Related

Possibility Of Saving All Info Related To Caller Number?

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

Looking For A String Not An Object.

Jul 23, 2005

I want to use the same function for a number of fields.

<input name="taxi1" type="text" id="taxi1" size="8"
(this,1)">

function myFunction(val, itm) {
}

What can I do to get the name of the text field "taxi1"? If I try to use
[val], I'm told it is an object. I'm looking for the string "taxi1".

View 2 Replies View Related

String To Object

Nov 24, 2006

how would I change this to an object that I can add onto a table?
And how would I add it to the table? Code:

View 3 Replies View Related

Return An Object From A String

May 19, 2006

reSplit is used to return an object from a string of name/value pairs.

pass reSplit()your own delimeters or use the defaults.

String.prototype.reSplit= function(d1,d2){
if(!d1) d1= /s*;s*/
if(!d2) d2= /s*=/;
var Obj= new Object, tem;
var A= this.split(d1);
var L= A.length;
for(var i= 0; i< L; i++){
if(!A[i]) continue;
tem= A[i].splat(d2);
Obj[tem[0]]=tem[1];
}
return Obj;
};
String.prototype.splat= function(delim){
var ax,L;
var d= this.match(delim);
if(!d) return this;
else{
ax= d.index;
L= d[0].length;
return [this.substring(0,ax), this.substring(ax+L), d[0]];
}
};

View 1 Replies View Related

Using An Array-string As An Object

Feb 27, 2010

What I'm trying to do, I think, is to use elements of an array as a part of an object. Here's a lil' code snippet:

Code:

I'm trying to insert each of the elements of the katMusik-array into the checked-line, thus checking the checkboxes with those names. However, it doesn't seem to work.

View 5 Replies View Related

How To Keep String From Being Converted To Object

Jun 5, 2011

In a MySQL database I have the following entry: "Fruits & Vegetables". I retrieve this to display on a webpage using PHP, convert to JSON, pass to client, process using JavaScript.

The PHP code that is passed to the client is:
Code:
$z = rawurlencode(json_encode($reqVar));
echo $z;
where $reqVar is the array of results queried from database, including one that is "Fruits & Vegetables".

When it's passed to client using AJAX, the JavaScript to process the string (decode it and then convert from JSON string to object using Prototype framework) is.
Code:
var response = decodeURIComponent(transport.responseText)
var respObj = response.evalJSON(true);

I can then display it in page. But when I pass it back to the PHP script using AJAX using the exact same process in reverse, at some point & is converted to & and if I re-enter it into the database it looks like "Fruits & Vegetables". How can i prevent this conversion? Does the order in which I convert to and from JSON and encode/decode need to be changed?

View 1 Replies View Related

Convert String To DOM Object?

Jul 21, 2004

I have this string: tr= "<tr><td>test</td></tr>";

And I need to convert this string to DOM object. Like this:

var tr= document.createElement("tr");

But with the content of tr element.

View 6 Replies View Related

Cast A String As An Refernce To An Object.

Jul 23, 2005

Hopefully this can be done and it is easy...

I have some object like

var a = new Object();
a.name = "Title";
a.vars = new Array(6);
a.vars[0] = "4";
a.vars[1] = "22";
etc...

for about 18 objects.

If I have a string like
var str = "a";

how can I reference object data, like str.vars[0]?

View 2 Replies View Related

JQuery :: ParseXML Object In To String?

Jun 26, 2011

I used below code to pass my xml sting.

Xml_string = <?xml version="1.0" encoding="UTF-8"?><layout>
<elements>
<i type="image" id="a18888201" [code].....

Now I wont to edit this xml_file and again convert this xml object to in string . It seems I can change the values. But I don’t know how to convert this (Xml_file) in to string.

View 2 Replies View Related

Create Object With Name Contained In String

Mar 25, 2006

Is there a way to do the following?

<script language="javascript" type="text/javascript">

function newfunction(objectName) {

// how can I create a new obect called whatever is contained in the objectName string?

}

//create a new object called myObject
newFunction("myObject");

myObject.getAttribute("objectAttribute")

</script>

View 2 Replies View Related

String Convert To A Object Array ?

Dec 10, 2009

I have a String formated in such as the javascript format

May I know is it posible to directly convert to var array?

Example:

But it look not work for me...

How can I do that? ( without using split function example var data = respond.split(","); )

View 9 Replies View Related

Converting String To DOM Object Reference?

Dec 5, 2010

I have searched the web and this forum for the answer to this but am unable to find a reasonable choice. So, this is the problem I am facing.

Code:
var str = "document.frames[0].document.frames[0]";
var str 1 = "document.frames[6]";
//Loop Starts
{
var obj1 = str + str1;

[Code]...

I know the easiest way to do this is to use eval() and it most definitely does work. The problem is that I have to use eval() inside a loop to check whether the reference is null and from what I hear, that is one of the most inefficient ways to code. I have searched for alternatives like using, var myFunc = new Function(string) and then calling myFunc(). But this does not work in my case. I cannot find any other alternative in this case. I guess one can say eval() is the only choice here but I am not too sure.

View 10 Replies View Related

Pass Object In Function Instead Of String?

Apr 28, 2011

In the following example, I use the function "SetUp(SBox,AObjStr)" to send an object reference to the function "Populate(SBox,SObj)".

Seems to work OK, but it is a 2 step process to assign the JSON objects to the selected drop-down boxes. Fairly easy, but somewhat tedious, to change to fewer or more levels as desired with a common bit of code.

However, what I would like to do is simplify it a bit more ... Is there a way to bypass the "SetUp" function to "Populate" the multi-level drop downs directly? I think what I'm looking for is a way to pass a string in the function that would be recognized as an object (in this case a JSON or other form of array) and be decoded to add options to the drop-down choices, but I don't have a clue as to how that might be accomplished without the extra "SetUp" function!

Code:
<html>
<head>
<title> Passing Object Indirectly </title>
<script type="text/javascript">

[Code]....

View 6 Replies View Related

Convert String To Date Object ?

Dec 16, 2005

Is it possible to convert a String of date like 12/25/2005 01:00PM to a Date object?

View 14 Replies View Related

Function: Cannot Pass A String And Use As An Object With Netscape!

Jul 20, 2005

Im looking to make work my script on both IE and Netscape. It works
fine in IE, but netscape cant handle "dynamic" variables. I need some
help!

Is there a CORRECT way to pass a string as parameter and then use it
as an object in Netscape? IE does that without problem... and Netscape
seems not able to handle it.. Code:

View 2 Replies View Related

JQuery :: How To Pass Object In JSON That Is Not String

Feb 3, 2011

I'm a beginner in Jquery and I have a big doubt, follow at bellow the code to be better viewed: The method below is static and Static methods do not work with instance, For this reason I passed the 'nameLabel' that the typeis Label by parameter, however I need to catch the exception and show it to the user.

[WebMethod]
public static string RetornaNomeCliente(string idCliente,Label nomeLabel){
string nomeCliente = String.Empty;
try {
nomeCliente = Cliente.RetornaNomeCliente(idCliente);
} catch (Exception e) {
nomeLabel.Text = e.Message.ToString();
} return nomeCliente;
}

But I'm using Jquery and this method is used in a Ajax Request and I use the Json to pass the datas, how showed below:
var idCliente= $("#<%= txtIDCliente.ClientID %>").val();
var nomeLabel = $("#<%= lblMensagem.ClientID %>");
var poligonal = "{ idCliente: " + idCliente + ", + lblMensagem: " + nomeLabel + " }";
But the problem is that I need to pass in my Json the nomeLabel with Label, but always a problem happen, because the same is showed like 'indefined'. How to solve this situation?

View 1 Replies View Related

Parsing A Response Object That Contains String Array

Aug 27, 2010

I have a string array in a class file that contains 5 values, which I need to display on the jsp page. but when I send it to the javascript it prints [Ljava.lang.String;@104f8b8 .what do i do about it. I am a new to javascript. Is there a way to get my array data from the response object.

View 1 Replies View Related

Converting Element Object To HTML String?

Aug 22, 2010

after i've built an element, can i convert that element to html? the current method i'm thinking is to append this element to a new <Div> and call the Div's innerHTML but it feels rather dirty. is there a better solution?

View 2 Replies View Related

Jquery :: Accessing Object Using Variable String

May 8, 2011

I have an object whose name is mural. I have assigned the name mural to the title of an anchor element. When user clicks and element I want to store the title of the anchor in a variable called sprite. I then want to access that object whose name corresponds to the sprite variable string.

Here is my code:
HTML Code:
var mural= new Object();
mural.top='0px';
mural.left=-'510px';

var stamps= new Object();
stamps.top='0px';
stamps.left=-'1886px';
var sprite=$(this).attr('title');
$(".image-holder").css("background-position",'sprite.top, sprite.left');

It's not working because the the variable sprite is just a reference to $(this).attr('title'), how do I make it reference the object? Oh and I know that .cc jquery statement probably wont work, I'm not sure yet of the correct way to have two values that don't need quotations in as the second argument.

View 1 Replies View Related

Cannot Convert To Object - Converting A String To Numeric

Sep 14, 2011

I think this is a problem converting (what is assumed to be) a string to numeric. or something like that.

rvs = s[i][j] * k;
Firefox Error Console says:
Uncaught exception: TypeError: Cannot convert 's[0]' to object
rvs is just a (temporary, holding) variable.
s is a [3][6] array on numeric values.
i, j and k all happen to be zero.
[Code]..

View 1 Replies View Related

How Can I Avoid Type-conversion (object Variable To String)

Jul 23, 2005

How can I avoid type-conversion (object variable --> string) when
passing an object variable to a function?

Example:
-->
catch(myerrorobject)
alert(myerrorobject.filename);
{
my_function('bla: ',myerrorobject);
}
<---

I get the "myerrorobject.filename" in the alert-Box, but I get an
"undefined"-error, if I try to access myerrorobject.filename (or other
properties) in the function "my_function". Why?

View 1 Replies View Related







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