Object Debugger
Nov 3, 2003
This is a script that frequently keeps me from using bad words.
It loops through an object and returns its properties in text (for alert) or html format.
Usage:
_viewObj(obj[,instanceName[,type[,levels]]]);
Ex:
var obj = {id:3,arr:[2,3,"str",{prop1:2,prop2:""}],nr:3}
alert(_viewObj(obj));
document.write(_viewObj(obj,"obj","html"));
Parameters:
pValue: The object
pName: Instance name of the object. Default: "input"
pType: Which type to be return (text or html). Default: "text"
pLevels: The max amount of levels. Useful if an object references a parent. Default: infinite
Returns:
A string with the properties
function _viewObj(pValue,pName,pType,pLevels,pObj) {
function objExists(pCurr) {
for (var i=0; i<pObj.length; i++) {
if (pObj[i]==pCurr) {
return true;
}
}
return false;
}
pType = new String(pType).toLowerCase();
if (new String(pName) == "undefined")
pName = "input";
if (new String(pType).search(/html|text/i) == -1)
pType = "text";
if (pLevels == "undefined")
pLevels = -1; /* Infinite */
if (typeof pObj == "undefined")
pObj = [];
var str="";
if (typeof pValue != "function") { // No functions / methods - just values
var br=(pType == "text"? "
" : (pType == "html" ? "<br>" : ""));
if ((typeof pValue == "object" && !!pValue) && (pValue.length) && (!pValue.substring)) { // An array
try {
for (var i=0;i<pValue.length;i++) {
if (pLevels==0) {
str+=br+pName+"["+i+"]: "+pValue;
}else{
str+=""+_viewObj(pValue[ i ],pName+"["+i+"]",pType,pLevels-1,pObj);
}
}
} catch (e) {
str+=br+pName+": "+pValue+" (Not an array)";
}
} else if (typeof pValue == "object" && !!pValue && (!pValue.substring)){ // An object
try {
for (var prop in pValue) {
if (pLevels==0) {
str+=br+pName+"."+prop+": "+pValue;
}else{
if (typeof pValue[prop] == "object" && objExists(pValue[prop])) {
str+=br+pName+"."+prop+": [Parent Object]";
}else{
pObj.push(pValue);
str+=""+_viewObj(pValue[prop],pName+"."+prop,pType,pLevels-1,pObj);
}
}
}
} catch (e) {
str+=br+pName+": "+pValue+" (Not an object)";
}
} else{// if (typeof pValue != "object") { // Simple value
str+=br+pName+": "+pValue;
}
}
return str;
}
edit:
Avoiding never-ending loops by checking for parent objects.
Ex:
var parentObj={id: 2};
var test={id: 1,par: parentObj};
parentObj.tst=test;
View 6 Replies
ADVERTISEMENT
Dec 23, 2005
Is there a free JavaScript debugger available?
View 5 Replies
View Related
Sep 29, 2006
What debugger would let me see the HTML in a div after I've added HTML
to the div using its innerHTML? That is:
var someInputHtml = prompt("input html");
var referenceToSomeDiv = document.getElementById("someDiv");
referenceToSomeDiv.innerHTML = someInputHtml;
When debugging, how do I now see what HTML is in the div "someDiv"?
Maybe there is a FireFox extension for this? Firebug?
View 5 Replies
View Related
Jul 20, 2005
I would like to download debugger for javascript.
Since I works only with IE I thought of trying using the Microsoft Script
Debugger.
I found the following URL
http://msdn.microsoft.com/library/d...tml/sdbug_1.asp
My problem is that I can't find the URL to download the debugger.
Any other JS debugger that works well for IE ?
View 5 Replies
View Related
Jul 20, 2005
I'm looking for a good javascript debugger.
View 3 Replies
View Related
Aug 13, 2003
I finally got tired of doing:
alert('myVar: ' + myVar);
and
str='' for(i in someObject) str+=i+': '+someObject[i]+'' alert(str);
and put together a little debugger to take care of that.
I bet I'm not the first one, but when it comes to JS my motto is "If you want to do it right.
Anyhow here is the demo, you are welcome to view and use the source, just leave the credits...
View 4 Replies
View Related
Jul 27, 2002
According to the Sitepoint FAQs, most serious programmers debug their scripts by hand, but when my javascripts don't work , I like to be told why, the more explicitly the better.
I used to have NN4 and its debugging was fantastic (certainly more helpful than IE and Opera, although theirs aren't too bad). I was just wondering what other people think is the best browser/resource for debugging javascript. If it's Netscape, does this mean I have to download the whole browser, and does the debugging vary with version number? Which would be the best to get? (Note: I'm only interested in its debugging capabilities, not its quality as a web browser).
View 11 Replies
View Related
Jul 20, 2005
Whenever I stop the IE script debugger it closes the browser window as well.
View 2 Replies
View Related
Jun 14, 2006
I recently learned about a new Javascript Debugger called FireBug. From what I've heard, it's pretty good. Here's the link: Code:
View 4 Replies
View Related
Sep 20, 2009
I have both firebug and venkman debuggers installed. Both seem to function yet neither works. I use firefox3.5.3., windows xp.
View 2 Replies
View Related
Sep 23, 2010
I'm pretty new to JS, used to be back-end guy with strong front-end skills (HTML, CSS), learning JS now and I have a huge problem.
I'm using Windows 7, coding mostly in NuSphere PhpED, but I see it doesn't work so well for JavaScript.
What's the best tool for JavaScript coding in Windows, maybe with built-in debugger (I hope there's something else than Firebug, Dragonfly etc.) with syntax coloring, and perfectly with a feature like this one
Maybe you do know the best syntax-help Windows editor for PHP too? (PhpED is not perfect IMO). Eclipse?
BTW - if there are any OSX based front/back-end webdevs - put screens of your editors features (JavaScript & PHP preferably). I'm thinking about switching to MAC, but haven't got cash for that at this moment (and I'm kind of Apple hater, however I believe in front-end field they have no contest).
View 1 Replies
View Related
Oct 14, 2010
Javascript issue: IE suggest bug but no code is reported in the debugger. Any ideas why IE doesnt find the broken code / or line
View 1 Replies
View Related
Oct 3, 2006
I have a javascript program that works fine under Firefox and on IE
when running XP, but is having a problem with IE running under Windows
2000 Pro.
On my personal XP development machine I have the Microsoft Script
Editor and I can set a breakpoint, step through code, inspect
variables, etc... with no problem.
On a machine where I am trying to debug this problem I am running
Windows 2000 Pro with IE 6. I installed the Microsoft Script Debugger.
When the program hits the exception the script debugger will come up
and show me the line where the error occurred.
I need to be able to inspect the variables to determine the problem.
However, from what I can tell, there isn't anywhere to inspect or watch
the variables in MSD?
View 4 Replies
View Related
Nov 19, 2011
I just got this script for a countdown on a website and I got it to work locally but when I upload it to the server i get the error "index.html:22 Uncaught TypeError: Object [object Object] has no method 'fancycountdown'".
I have checked to make sure all other javascript files are loading and they are and I can't figure out whats wrong. You can see it [URL]
View 2 Replies
View Related
Oct 9, 2010
I have the following code:
A = {
"value": "a",
};
B = A ;
B.value = "b";
alert (A.value); // => b
I expected A.value to be "a". how can I change values of a new object, without changing the parent-object?
View 6 Replies
View Related
Oct 5, 2010
13 line causes this exception. Function is called insied of ready() handler. function renderGridSystemRecursively(scheme, container){
[Code]...
View 2 Replies
View Related
Oct 15, 2009
I have come across an issue that only happens with IE.I have a custom save function that is designed to handle different ajax submits but I will simplify it for debugging. The issue is that once I make a submit everthing is fine at first. Then once I try to submit a second time it craps out. I am checking to see if there is an onsubmit function and then executing it like so before continuing. After the inital submit it is no longer found. When I alert the typeof document on the form it returns object but when I add the onsubmit it says object expected or object is null or undefined.
Code:
function secureBarSubmit(formId)
{
alert(typeof document.getElementById(formId)); // object always
alert(typeof document.getElementById(formId).onsubmit); // func first time then it is broken
[code]...
View 1 Replies
View Related
Jul 1, 2009
Can assign a new function to a built-in object in Firefox:
But IE and Opera don't have a MouseEvent or HTMLElement that can be set up in the same way. Can you do this in IE or Opera, or just Firefox, and maybe Webkit?
View 1 Replies
View Related
Nov 4, 2009
every time I try and alert:
[ { number:0, secondnumber:0 }, { number:2, secondnumber:1 }, { number:1, secondnumber:2 } ]
it just shows [object object], [object object], [object object]. Why is this and what can I do to make the record be shown as it is above in an alert?
View 1 Replies
View Related
Oct 6, 2011
Is there any way at all to create a new template object that inherits from the built in Date object so as to be able to add new methods to that child object without adding them to the built in Date object? I've tried everything I can think of and as far as I can tell it keeps referencing the Date function instead of the Date object and so doesn't work.
View 3 Replies
View Related
Aug 5, 2011
I have an object with a single Method to load content from a xml file. The problem is... how do I add a property to the object to store the data loaded?? I tryed adding a simple Array inside the object, but didn't work.
[Code]...
View 2 Replies
View Related
Sep 23, 2011
I am using a Photo Gallery script called Galleria which uses jQuery/JavaScript to display photos. On my index page load (only in Internet Explorer), a message box pops up saying "Message from Web Page [object Object]". After clicking OK the photo gallery loads and there is no problem.No idea how to fix this, or really what the error means. You can view the error from my site here
View 3 Replies
View Related
Mar 10, 2011
I am trying some simple things with javascript and trying to use it in a object oriented way. However I am now facing a problem in which I can't access an object variable from an object method. I am using jQuery.
My code is as follows;
Code:
My problem is that the variable msg1 does not work when accessed from function called from the jQuery get function. I get the message undefined. Therefore I am wondering, is there a way how I can access msg1 of my object instance from the get function of jQuery?
View 1 Replies
View Related
Mar 20, 2010
I created a method for displaying an object's properties:
As long as renderfunction = false, the object is fine coming out of this function.
However, if I change renderfunction to true, all my properties become undefined. Why isn't this working as I expect it to?
View 1 Replies
View Related
Apr 5, 2011
How would I go about copying all the prototype functions AND the constructor from one object into another object, and then call them?
I know I can use this.example.call(this), but that's not an acceptable solution. I want to deploy this style over dozens, potentially hundreds of objects.
View 7 Replies
View Related
Apr 29, 2010
I am trying to alert the ID of a particular menu that I have clicked on and I am getting object,object. Instead of the name of the ID.
[Code]...
View 1 Replies
View Related