JavaScript - How Do I Understand Messages In The Error Console?
What can I do to find out what the errors in the error console mean?
Similar TutorialsI would like to have a button just like for firebug, for error console, and that it would open error console window like for firebug. Is there a setting for that in FF, or some kind of addin outthere ?
Hello, Error Console tells me : exp is null Line 10 This does not make any sense to me. Could someone look at the short script below and tell me why I get this message? I know how to make this script work, but I just want to understand why function changePar cannot access the variable exp in the script below. Thank you very much. <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"> <head> <title> Exercise 2</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <script type="text/javascript"> exp=document.getElementById("experiment"); function changePar() { exp.getElementsByTagName("button")[0].onclick=function() { document.getElementById("changingParagraph").innerHTML="Hello World"; } } window.onload=changePar; </script> </head> <body> <div id="experiment"> <button>Click Here</button> </div> <p id="changingParagraph"></p> </body> </html> </code> Strange problem here... I'm implementing google's JS tracking code verbatim which determines whether or not the current site is using HTTP or HTTPS. It builds a dynamic URL used as the "SRC" parameter in the SCRIPT statement. On browsers I'm testing with(FF, IE, Chrome) there's no problem running the code. However, there are some people in the office who get an FF or IE error (same versions as mine) on the URL as the SRC parameter. The error, in the FF Error Console, is this: Quote: illegal character http://www.google-analytics.com/ga.js ? ? ? ? --> question marks appear in console I can't figure it out since I can't create this error on any of my browsers. Could this be related to something like browser security settings or add-ons? I had posted a previous forum for help and solved a problem. However, than the links lost their formatting in the browser. I kept going as I am doing a lesson out of a textbook and the links are fixed now, but my coded object is not showing up. There should be a calendar in the upper righthand corner. I posted the javascript first and only a section of html after. Code: function calendar() { var calDate = new Date("March 18, 2011"); document.write("<table id='calendar_table'>"); writeCalTitle(calDate); writeDayNames(); writeCalDays(calDate); document.write("</table>"); } function writeCalTitle (calendarDay) { var monthName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var thisMonth=calendarDay.getMonth(); var thisYear=calendarDay.getFullYear(); document.write("<tr>"); document.write("<th id='calendar_head' colspan='7'>"); document.write(monthName[thisMonth]+" "+thisYear); document.write("</th>"); document.write("</tr>"); } function writeDayNames() { var dayName = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); document.write("<tr>"); for (var i=0; i < dayName.length; i++){ document.write("<th class='calendar_weekdays'> "+dayName[i]+"</th>"); } document.write("<tr>"); } function daysInMonth(calendarDay) { var thisYear = calendarDay.getFullYear(); var thisMonth = calendayDay.getMonth(); var dayCount = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (thisyear % 4 == 0) { if((thisyear % 100 != 0) || (thisyear % 400 == 0)){ dayCount[1] = 29; //this is a leap year } } return dayCount[thisMonth]; } function writeCalDays(calendarDay){ var dayCount = 1; var totalDays = daysInMonth(calendarDay); calendarDay.setDate(1); var weekDay = calendarDay.getDay(); document.write("<tr>"); for (var i = 0; i < weekday; i++) { document.write("<td></td>"); } while (dayCount <= totalDays) { if (weekDay == 0) document.write ("<tr>"); document.write("<td class='calendar_dates'>"+dayCount+"</td>"); if (weekday == 6) document.write ("</tr>"); dayCount++; calendarDay.setDate(dayCount); weekDay = calendarDay.getDay(); } document.write("</tr>"); } Code: <title>The Chamberlain Civic Center</title> <link href="ccc.css" rel="stylesheet" type="text/css" /> <link href="calendar.css" rel="stylesheet" type="text/css" /> <script src="cal.js" type="text/javascript"></script> </head> <body> <div id="head"> <script type="text/javascript"> calendar(); </script> <img src="logo.gif" alt="Chamberlain Civic Center" /> </div> If you want, I can upload the files to my school server so you can view the webpage in a browser. The error console says that there is a missing parenthetical where I have the ! symbol. I don't see that. Also it says that calendarDay is not defined. Hi all, I have an issue that seems to relate to IE6 only. Tested and working in IE8 and FF3. If you go to the following page and click 'Buy Now' at the bottom of the page to submit the form the jQuery validate library error messages are displayed at the top of the page, rather than next to the corresponding form element: http://bit.ly/cc97GP Any help appreciated with this one. Seems to work fine in IE8 and FF3 as mentioned. Best Regards, Picco Hi, Could I use javascript code to stop Internet Explorer script error messages? Bob Kuspe Hi, I'm using HTA with iframes contains external web pages, lot of pages (external - not mine) contains errors and while running 'script error' pops. If running the same pages in IE there are only error notice in the bottom left side of the browser. Can I do something to ignore those script error popups in my HTA? (I'm using also Javascript for my HTA) Could I use javascript code to stop Internet Explorer script error messages? Regards Bob I'm working with greasymonkey scripts. Firefox JS console would always display GM script errors, but all of the sudden it stopped doing that. Script just won't load and no errors are displayed. I didn't touch any settings, yesterday they were showing fine, today none are displayed. Would appreciate any help.
Hi, i'm having problems with my console game, when i type in help when testing it just doesn't do anything, it's probarly a stupid mistake but i can't find what i did wrong :s index.html code Code: <html> <head> <script type="text/javascript" src="scripts/jquery.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Console Game Project</title> </head> <body> <div id="console"> <p id="message_startgame">Welcome to Nieli's game! To control the game you must type in commands</p> <p id="area_northcorridor">You are in the north door. There is a sword on the ground.</p> <p id="message_help" style="display: none;">Here is a list of commands</p> <!-- PLACEHOLDER: THIS IS WHERE EVERYTHING WILL BE INSERTED BEFORE --> <div id="placeholder"></div> <form onsubmit="return false;"> <input type="text" size="50" autofocus="autofocus" id="command_line" /> </form> </div> <script type="text/javascript" src="scripts/game.js"></script> </body> </html> game.js code Code: //been to variables beentonorthdoor = true; // //Item variable sword = false; // //Current room currentroom = "n_corridor"; // $(document).ready(function() { $("form").submit(function() { var input = $("#command_line").val(); if (input == "help") { $("#message_help").clone().insertBefore("#placeholder").fadeIn(1000); } $("#command_line").val(""); }}; }}; I have on my website ( www.nieeli.com/game/ ) the index.html, then a folder scripts with jquery.js and game.js in.. Could anyone help me Oh, just noticed there is a Jquery help section... Sorry i'm working with a javascript on a drupal website, but the saving function seems to work only as soon as i click 2 times on the "save" button. the code that fires the function is: Code: var param ="&usuario="+usuario+"&nivel="+nivel+gano+porc_gano+gasto+porc_gasto+tengo+porc_tengo+debo+ porc_debo+plazo_debo; var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = server_direction +"setMisDatos?callback=respuestaGuardarMisDatos¶m="+encodeURIComponent(param); var h = document.getElementsByTagName("script")[0]; h.parentNode.insertBefore(s, h); //or h.appendChild(s); the chrome console tells me the error is in the last line i copied, but i don't undertand what kind of error it is. using chrome console (specifically the "network" one), i see that it's written in red, status/text "failed", type "undefined" size/content "13 B / 0 B"; when it works it's: status/text "200/OK", type "text/json", size/content "256 B/ 38B". i'm not an expert with this, is there some more information that could be useful? the code fires a netbeans function, that stores data to a postgresql database, so i have like 100 variables that has to be stored when i click on the "save button". Actually before i put parentNode.insertBefore, there used to be appendChild(s), but then i found out this algorithm from google analytics, which seems to be working better than the previous one. Having said that, i can tell you that the GET works after the first time i click perfectly, with some weird things happening, like if i browse another tab for a while, then go back to the page, and click on save, it won't work again (same error). The variables are written like this: Code: var plazo_debo_casa1 = (getValor("plazo_debo_casa1")); var plazo_debo_casa2 = (getValor("plazo_debo_casa2")); var plazo_debo_casa3 = (getValor("plazo_debo_casa3")); var plazo_debo_prestamo1 = (getValor("plazo_debo_prestamo1")); var plazo_debo_prestamo2 = (getValor("plazo_debo_prestamo2")); var plazo_debo_prestamo3 = (getValor("plazo_debo_prestamo3")); var plazo_debo ="&plazo_debo_casa1="+plazo_debo_casa1+"&plazo_debo_casa2="+plazo_debo_casa2+"&plazo_debo_casa3="+plazo_debo_casa3+"&plazo_debo_prestamo1="+plazo_debo_prestamo1+"&plazo_debo_prestamo2="+plazo_debo_prestamo2+"&plazo_debo_prestamo3="+plazo_debo_prestamo3; and then together in the "param" variable. Is it clearer now? i tried to copy document.head.appendChild(s); instead of parentNode.insertBefore(s,h), but it still behaves the same way. Still not any suggestions? This is part of the javascript file loading on my page, and since the function setMisDatos is in netbeans and it works correctly as soon as it's fired (at least, that's what i notice after the first click), i don't think it's worth copying part of it here, right? are there maybe too many variables for the GET method? is there a way to check GET errors? i'm sorry for not being an expert but i would really like some help here. I use console.log to print the dom element info, but some results make me very confused.The code is below, you can paste it to a file and browse it. //********************** <html> <head> </head> <body> <script type="text/javascript"> function showObjInPage(obj) { document.write("=======================================<br/>"); document.write((typeof obj) + "<br/>"); document.write("length: " + obj.length + "<br/>"); ///!!! 0, may ok document.write(obj); //!!!!!write nothing for (var prop in obj) { document.write(prop + " = " + obj[prop] + "<br/>"); } document.write("=======================================<br/>"); } function consoleLog(obj) { console.log("=======================================<br/>"); console.log((typeof obj) + "<br/>"); console.log("length: " + obj.length + "<br/>"); //!!!!! this is the confuse, it is 0, but the code below show obj correct! console.log(obj); //!!! write all the p elements for (var prop in obj) { console.log(prop + " = " + obj[prop] + "<br/>"); } console.log("=======================================<br/>"); } var elems = document.getElementsByTagName('p'); //console.log(elems); //console.log(elems.length); showObjInPage(elems); consoleLog(elems); </script> <p>p1</p> <p>p2</p> <p>p3</p> <p>p4</p> </body> </html> I want to print the p elements info use console.log, it is ok to log the elems, but the elems's length is 0, so it is not consistent! Maybe my code need to write after the 'p' element, but the problem is very confused. Is it a chrome console.log bug or just I do something wrong? Hi, I am very new to JavaScript. I am trying to understand what this does and I am hoping someone here can help. A user fills in some data for a search and results are displayed on the page but there is no option to save the results. I would like to be able to just dump them into a text file, but I have no way of changing this code.. so I'm thinking if I could find out specifically what this is doing then maybe some other tool or command can be used to get the results and save them into a file (maybe wget?? or something). Here is the code: <script type="text/javascript">//<![CDATA[ $(document).ready(function() {$.get('\x2fTraceMessage.mvc\x2fAsyncMessageList\x2f736251', { s:'google\x40google.com', r:'yahoo.com', d:'1\x2f10\x2f2012 2\x3a18\x3a37 AM', e:'1\x2f16\x2f2012 2\x3a18\x3a37 PM', i:'', a:'-5' }, function(data) { $('#message_trace_list').html(data); }); }); //]]></script> Thanks in advance for any help! Hey, so I've been trying (in vain) to get my head around how this little script is doing what it's doing. Code: var msg = "From Person (*Account): .tp" var reg = /^.*\(\*(\w*)\)(\swhispers)?\s*:\s\.(.*)$/gi; if (msg.match(reg)) { var sender = msg.replace(reg, "$1"); var command = msg.replace(reg, "$3"); Say(sender+" told me to "+command); Delay(500); } So there is this message that comes in, and somehow this script is able to just take the characters after the . as well as getting the word between (* and ) . And all this from just one line of code?? If you've got some free time and are able to help me understand what the "var reg" line is doing I'd be so thankful. Feel free to assume I'm new at Javascript, I've done a little C and VB, but never java. Thanks in advance Hi! I was wondering if anyone could help with the code below. I think there is something wrong with the "thecontents[] part below. Could anyone have a look and possible email me with a finished version... Code: <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><form name="ddmessage"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><select name="selectbox" size="1" onChange="changecontent(this)"> <option selected value="What is JavaScript?">What is JavaScript?</option> <option value="Why learn JavaScript?">Why learn JavaScript?</option> <option value="What do you think of the site?">What do you think of the site?</option> <option value="I'd like to feature one of these codes on my site.">I'd like to feature one of these codes on my site.</option> </select><br> </td> </tr> <tr> <td width="100%"><textarea rows="8" name="contentbox" cols="35" wrap="virtual"></textarea><br> <font face="arial" size="-2">This free script provided by <a href="http://javascriptkit.com">JavaScript Kit</a></font> </td> </tr> </table> </form> </td> </tr> </table> <p> <script language="JavaScript"> /* Drop down messages script By JavaScript Kit (http://javascriptkit.com) Over 400+ free scripts here! */ //change contents of message box, where the first one corresponds with the first drop down box, second with second box etc var thecontents=new Array() thecontents[0]='Its what I used to make this :/' thecontents[1]='I wouldn't reccommend it, its rather hard. Though, I hate to blow ones own trumpet, I am learning to do it rather well.' thecontents[2]='I hope you have enjoyed it! Email support@matthewjmorris.co.uk with your comments. Also, if you have any bits to go on this page, email Support aswell with the code, instructions for installing the code and your name! Your name may appear here, along with your code!' thecontents[3]='support@matthewjmorris.co.uk' //don't edit pass this line function changecontent(which){ document.ddmessage.contentbox.value=thecontents[which.selectedIndex] } document.ddmessage.contentbox.value=thecontents[document.ddmessage.selectbox.selectedIndex] </script> Thanks! I am taking a class to learn javascript, and this book has so many typo's, just typing in the code they suggest, I can never get this to work. I am NOT a programmer...but a 50 something year old person, wanting to learn more about web design. I applaud those who actually understand javascript. I think it is amazing how it can do so many things to a web page. If you can help, I certainly would appreciate it. This is the code for the website: Code: <html> <head> <!-- New Perspectives on JavaScript Tutorial 3 Case Problem 1 The Lighthouse Author: Date: Filename: clist.htm Supporting files: lhouse.css, list.js, logo.jpg --> <title>The Lighthouse</title> <link href="lhouse.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="title"> <img src="logo.jpg" alt="The Lighthouse" /> The Lighthouse<br /> 543 Oak Street<br /> Delphi, KY 89011<br/> (542) 555-7511 </div> <div id="data_list"> </div> <div id="totals"> </div> </body> </html> This is the javascript: Code: <html> <head> <!-- New Perspectives on JavaScript Tutorial 3 Case Problem 1 The Lighthouse Author: Date: Filename: clist.htm Supporting files: lhouse.css, list.js, logo.jpg --> <title>The Lighthouse</title> <link href="lhouse.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="title"> <img src="logo.jpg" alt="The Lighthouse" /> The Lighthouse<br /> 543 Oak Street<br /> Delphi, KY 89011<br/> (542) 555-7511 </div> <div id="data_list"> </div> <div id="totals"> </div> </body> </html> This is the cascading style sheet: Code: /* New Perspectives on JavaScript Tutorial 3 Case Problem 1 Filename: lhouse.css This file contains styles used in the clist.htm file */ #title {width: 600px; text-align:right; color: rgb(192,142,90); border-bottom: 1px solid rgb(232,182,130); margin-bottom:9px; font-size:10pt; height: 100px} #title img {float: left} #data_list {float: left} table {font-size: 8pt; font-family: Arial, Helvetica, sans-serif; border: 1px solid brown; margin-right: 20px} .yellowrow {background-color: yellow} th {color: white; background-color: brown; padding: 2px 5px} td {vertical-align: top; padding: 2px 5px} .amt {text-align: right} #totals table {font-size: 12pt} #totals table th {text-align: left} #totals table td {text-align: right; width: 75px} #totals table #sumTitle {text-align: center; background-color: yellow; color: black} 1. suppose to add a script element that points to the list.js file 2. Under this element insert another script element that contains the function amountTotal(). The purpose of this is to return the sum of all of the values in the amount array. There are no parameters for this fuction. Then add the following commands to the function: Declare a variable named total, setting its initial value to 0. Create a for loop that loops through all of the values in the amount array. At each iteration of the loop add the current value of the array item to the value of the total variable. Then after the for loop is completed, return the value of the total variable. 3. locate the div element with the id "data_list" Within the div element add a script element that contains the following commands: a. write the following code to the document: <table border='1' rules='rows' cellspacing='1'> <tr> <th>Date</th><th>Amount</th><th>First Name</th><th>Last Name<.th><th>Address</th> </tr> B. Create a for loop in which the counter variable starts at 0 and while the counter is less than the length of the amount array increase the counter in increments of 1. C. Every other row in the data list is to be displayed with a yellow background; to do this, within the for loop insert an IF condition that tests whether the counter variable is divisible evenly by 2 using the % modulus operator. If the counter variable is divisible by 2 write the following HTML tag: <tr> Otherwise write the tag, <tr class='yellowrow'> D. next within the loop write the following html code to the document: <td>date</td> <td class='amt'>amount</td> <td>firstName</td> <td>lastName</td> where date, amount, firstName and lastName are the values of the date, amuont, firstName, lastName arrays fro the index indicated by the current value of thefor loop's counter variable. E. Finally within the for loop, write the html code <td>street<br/> city, state zip </td> </tr> where street, city, state and zip are the values of the street, city state and zip arrays for the current index value. 4. go to the div element with the id "totals" insert a script element that writes the following html code to the document. <table border='1' cellspacing='1'> <tr> <th id='sumTitle' colspan='2'> summary </th> </tr> <tr> <th>Contributors</th> <td>contributions</td> </tr> <tr> <th>Amount</th> <td>$total</td> </tr> </table> where contributions is the length of the amount array and total is the value returned by the amountTotal() function you created earlier. Supposedly when complete, a list of 35 contributions totalling $5175 is displayed on the table and that alternate rows of the contributor list are displayed with a yellow background. If this makes any sense to someone who likes a challenge...I would appreciate hearing from you. I feel like I am taking an exam of a foreign language and I missed all the classes prior to the exam. We are getting NO (ZERO) help from teachers. Hi all, I've been working with the book "DOM Scripting: Web Design with JavaScript and the Document Object Model, Second Edition" It's available on the Safari ebooks library collection, which I get a subscription to through my school. It seems like a really good book, but in chapter 7 they get to this function and don't really explain it much: Code: function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } I understand the first part, where it stores window.onload into the variable oldonload, and then checks to see if window.onload is already handling a function. But I don't understand why it calls the variable oldonload(which then turns into a function with the (); right?) and then the func parameter somehow doesn't get overwritten. If anyone could explain this or point me in the direction of an online article or instructional book that might explain it better, I would really appreciate it. I sometimes see that some people use this expression: event = event || window.event Why people need to do this? What does it mean? I have seen this code-piece different places - to use to make a webpage redirect if it is a mobilephone. I don't quit understand the code - especially the line: if (redirectagent.indexOf(redirect_devices[i]) != -1) - why -1 ? Please help me - I would be so thankful. Code: <script language=javascript> var redirectagent = navigator.userAgent.toLowerCase(); var redirect_devices = ['vnd.wap.xhtml+xml', 'sony', 'symbian', 'nokia', 'samsung', 'mobile', 'windows ce', 'epoc', 'nitro', 'j2me', 'midp-', 'cldc-', 'netfront', 'mot', 'up.browser', 'up.link', 'audiovox', 'blackberry', 'ericsson', 'panasonic', 'philips', 'sanyo', 'sharp', 'sie-', 'portalmmm', 'blazer', 'avantgo', 'danger', 'palm', 'series60', 'palmsource', 'smartphone', 'rover', 'au-mic', 'alcatel', 'ericy', 'vodafone', 'wap1', 'wap2', 'teleca',, 'lge', 'lg-', 'iphone', 'android', 'htc', 'dream', 'webos', 'bolt', ]; for (var i in redirect_devices) { if (redirectagent.indexOf(redirect_devices[i]) != -1) { location.replace("http://www.example.com"); } } </script> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script src="https://code.oovoo.com/webrtc/oovoosdk-0.0.7.min.js"></script> <script type="text/javascript"> function TestId() { WebService1.GetAppId(onSuccess, onFailure); } //situation 1 function onSuccess(result) { alert(result); } //situation 2 //function onSuccess(result) { // return result; //} function onFailure(result) { alert("Error Invoking the Web Service..."); } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" ID="scriptManager"> <Services> <asp:ServiceReference Path="~/WebService1.asmx" /> </Services> </asp:ScriptManager> <div> <video id="localVideo" style="width: 300px; height: auto;" autoplay muted></video> </div> </form> <script type="text/javascript"> TestId(); // This line is working in situation 1 (onSuccess method situation 1) //BUT, WHEN I COMMENT METHOD IN SITUATON 1 AND UNCOMMENT SITUATION2 THEN LINE BELOW IS NOT WORKING var a = TestId(); //THIS LINE IS NOT WORKING WHEN SITUATION2 IS ACTIVE </script> </body> </html> I'm totally new when it comes to JavaScript and I'm trying to learn new things. Here I found the codes I tried it and it works but I would like to have comments for the code to understand how they have proceeded. can someone help me and explain these codes with comments? I really appreciate it. Code: var config = { "tags": "vfx+compositing", "user": "andreasl", "scriptTagTarget": "scriptTagDiv", "deliciousTarget": "deliciousLinks", "callbackFunction": "fetchDelicious" }; window.onload = function() { var url = 'http://feeds.delicious.com/v2/json/' + config.user + '/' + config.tags + '?callback=' + config.callbackFunction; var scriptDiv = document.getElementById(config.scriptTagTarget); addScriptTag(url, scriptDiv); }; function addScriptTag(url, scriptDiv) { if (scriptDiv.hasChildNodes()) { scriptDiv.removeChild(scriptDiv.firstChild) }; var scriptElement = document.createElement('script'); scriptElement.setAttribute('src', url); scriptDiv.appendChild(scriptElement); } function fetchDelicious(json) { var html = ""; for (var i = 0; i < json.length; i++) { var uri = json[i].u; var description = json[i].d; var tags = json[i].t; //array var time = json[i].dt; //var n = json[i].n; //new? var author = json[i].a; var bHtml = "<li><a href=\":u\">:d</a>:t</li>".replace(":u", uri).replace(":d", description); var tagHtml = ""; for(var n = 0; n < tags.length; n++) { tagHtml += "<li><a href=\"http://delicious.com/:u\">:d</a></li>".replace(":u", [author,tags[n]].join("/")).replace(":d", tags[n]); } tagHtml = "<ul>" + tagHtml + "</ul>"; html += bHtml.replace(":t", tagHtml); } html = "<ul>" + html + "</ul>"; document.getElementById(config.deliciousTarget).innerHTML = html; } |