Looking For Javascript Debugger
Jul 20, 2005I'm looking for a good javascript debugger.
View 3 RepliesI'm looking for a good javascript debugger.
View 3 RepliesAccording 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).
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 RelatedIs there a free JavaScript debugger available?
View 5 Replies View RelatedWhat 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?
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 ?
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...
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;
Whenever I stop the IE script debugger it closes the browser window as well.
View 2 Replies View RelatedI 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 RelatedI'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).
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 RelatedI 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?
I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):
index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>
<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>
showimage.js
------------
function newWindow1(pic,sitename)
{
picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}
resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}
Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.
Attached is a simple HTML file that adds and delete rows. In the add
row function I set an attribute "onClick" this triggers the
testMessage() function. When I try this in Firefox it works just fine
however on IE it just refuses to work.
What is interseting is the ROW that already exists has a similar
'onClick' event which works when the page is loaded, but subsequent
"row" additions to the table to not work in IE. Code:
two possibilities or the attribute type of script:
text/javascript (the one i usually use) application/x-javascript
what are the differencies between both?
depends on the html content?
for example html 4.0.1 versus xhtml 1.1?
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties
Line: 8
The line that the javascript console is showing an error for is in italics.
code from page:
<html>
<head>
<script type="text/javascript">
var defaultCols="100px,*";
var hiddenCols="0px,*";
function ShowHideMenu(){
theFrame = document.getElementById("framed");
if(theFrame.cols == defaultCols) theFrame.cols=hiddenCols;
else theFrame.cols=defaultCols;
}
</script>
<frameset cols="100px,*" name="framed">
<frame src="lframe.htm" name="frameMenu">
<frame src="mframe.htm" name="content">
</frameset>
</head>
<body>
</body></html>
Come someone let me know what I'm doing wrong here?
I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:
1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks".
2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"
Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?
and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?
View 2 Replies View RelatedI am looking for a method to extract the links embedded within the
Javascript in a web page: an ActiveX component, or example code in
C++/Pascal/etc. I am looking for a general solution, not one tailored
to a particular page/script.
Hopefully, the problem can be solved without recreating a complete
Javascript interpreter. Any ideas?
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
View 2 Replies View RelatedI would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:
Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?
Ok so, this is my purpose:
- to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML
Why?
-Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering
My problem:
Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed
For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')"
if I use xxx.innerHTML=text, nothing happens
My 1st solution:
Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt):
if I eval the code, it deletes my current page and renders a new one
for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text
What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML
Is this even possible? How would you go about it?
I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...
Just a quickie: is it possible to place javascript within javascript? The following is the code I am using to create a pop-up for a picture gallery. I would like to place a banner from a banner exchange in bold under each photo. When I use the code below I get an error message:
<SCRIPT language=JavaScript>
<!--
function openpic(pic_name) {
myWin= open("", "displayWindow", "width=640,height=510,status=no,toolbar=no,
menubar=no,scrollbars=yes,resizable=yes,alwaysraised=yes");
myWin.document.open();
myWin.document.write("<html><head><title>" + pic_name + "</title>");
myWin.document.write("</head><BODY><center><TABLE CELLPADDING=Ɔ' CELLSPACING=Ɔ' WIDTH=òr'>");
myWin.document.write("<br><img src=kate/image"+ pic_name + ".jpg><br>");
myWin.document.write("<br><br><BR><br><BR><br><BR>");
myWin.document.write("<script language='javascript' type='text/javascript' src='http://www.linkbuddies.com/ad.go?id=134039+2&n=3'></script>");
myWin.document.write("</center></body></html>");
myWin.document.close();
}
//-->
</SCRIPT>
Basically, on one of my sites I'm running adsense and today I added Chitika. The problem is, I can't run those type of ads through my banner advertising program.
The banner advertising program calls the banners/HTML from code like this:
<script language=JavaScript src=http://www.mysite.com/advertise/abm.asp?z=1></script>
And using that program I'm able to either choose a banner or HTML I want to display when that code above is used. It displays HTML ok... but when I try to run an ad of either adsense or chitika nothing displays on the page. The code that would be called is:
<script type="text/javascript"><!--
*Chicika code in here*
//--></script>
<script src="http://xxx/xxx/mm.js" type="text/javascript">
</script>
So... it looks like I can't have javascript call another javascript to display on a page. My question is then... how can I edit the above to make it work or how can I work around this problem? I'd really want this to work with Chitika and not so much with adsense... but it appears both Chitika and Adsense use similar javascript code.
is it possible to use functions from javascript file A.js in javascript file B.js?
View 5 Replies View Related