JavaScript - Unexpected Token
Hello, I do not have a lot of experience with Java and my HTML skills have not been put to use in a few years. The problem that I am having is trying to call a .js from an IIS footer file. The script is
Code: <!-- Piwik --> <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://216.128.27.18/" : "http://216.128.27.18/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); </script><script type="text/javascript"> try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 25); piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} </script><noscript><p><img src="http://216.128.27.18/piwik.php?idsite=25" style="border:0" alt="" /></p></noscript> <!-- End Piwik Tracking Code --> When added directly to the <body></body> of the html it works but i want to append it to all pages with a footer. I created an piwik.js with that above code then made an html file with Code: <script src="piwikfooter.js" type="text/javascript"></script> It does try to call the script but I get an error when loading the site piwikfooter.js:2Uncaught SyntaxError: Unexpected token< Any help would be very much appreciated. Similar TutorialsHello i'm using TinyceEditor in my website and i'm using AjaxFileManager to upload images. It works very good in my localhost, but in the remote server while uploading image an error appears (" Syntaxerror: unexpected token < ") and uploading stop. please i need the answer quickly Hi i have set up a token key to give me some extra protection against direct url access to the page but i wanted to make it random. at first i used session token but it is not set until after a page refresh on login so this has to be its own deal.. i have found several javascript random codes but how to i pass that value to the window call.. here is the window call.. as you can see right know i have it hard coded as one token all the time. i just need it random and then sha1 (or md5) Code: function url_chat(){ chatwindow = window.open("<?=$CONST_MY_ROOT?>/mychat/chat/index.php?tok=0ed61bdd3a8a86f39e6b4abd01ba4e3649d0ec1c", "chatwindow", "location=0,status=0,scrollbars=0,menubar=0,resizable=0,width=950,height=550"); } i could use this i guess but i dont know how to get that value to the window call above. Code: document.write(Math.floor(Math.random()*999999999999999999)); I'm making a javascript POST that returns some information in this format. It's copied from the web API website I'm developing from. Returns a token on success. Code: { "errors": [ ], "warnings": [ ], "data": { "token": "ta98585435afabcf26319e2038a09f40" }, "page": { "current": 1, "total": 1 } } How can I get the data.token bit out specifically? public classTestGeometricObject{ /** Main Method */ public static void main(String[] args) { //Declare and initialize two geometric objects GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangles(5,3); System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2)); //Display circle displayGeometricObject(geoObject1); //Display rectangle displayGeometricObject(geoObject2); } /**A method for comparing */ public static boolean equalArea(GeometricObject object1, GeometricObject object2) { return object1.getArea()==object2.getArea(); } /**A method for displaying a geometric object*/ public static void displayGeometricObject(GeometricObject object){ System.out.println(); System.out.println("The area is " + object.getArea()); System.out.println("The perimeter is " + object.geetPerimeter()); } } public classTestGeometricObject{ /** Main Method */ public static void main(String[] args) { //Declare and initialize two geometric objects GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangles(5,3); System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2)); //Display circle displayGeometricObject(geoObject1); //Display rectangle displayGeometricObject(geoObject2); } /**A method for comparing */ public static boolean equalArea(GeometricObject object1, GeometricObject object2) { return object1.getArea()==object2.getArea(); } /**A method for displaying a geometric object*/ public static void displayGeometricObject(GeometricObject object){ System.out.println(); System.out.println("The area is " + object.getArea()); System.out.println("The perimeter is " + object.getPerimeter()); } } Hi there, i have a dynamic form that is populated via a sql query (WHERE $AVAILABLE_PRODUCT > 0) hence the javascript that is called onchange has dynamic field names. i used numbers. the for loop works fine: Code: var numberOfFields = document.order_form.elements.length; for (var i=1; i<numberOfFields-3; i=i+4) { if (document.order_form.elements[i].value > document.order_form[i+3].value) { alert(document.order_form.elements[i].value + ' > ' + document.order_form[i+3].value); } .... } Alert Box shows: 3 > 17 or similar (where 17 is the number of items on stock, and three the number of items ordered.) all other calculations with that form work fine. any idea? Ok, so I wanted to use the following object to copy the contents of the Report array at index [file][entry]. Code: Selected = { fileIndex : file, entryIndex : entry, Entry : Report[file][entry] } This was done so that the user may perform modifications to the entry without updating the entry until I have run validation on the input. Then I used Code: if(valid) Report[Selected.fileIndex][Selected.entryIndex] = Selected.Entry to finish up. I noticed that the Report array was getting the new input even when I didn't validate. I used the following to view all the contents of the Report Array in real time Code: window.setInterval('SHOW_ARRAY();',200); Report=[]; function SHOW_ARRAY(){ HTML('ReportDebug','') //Reset "ReportDebug" HTML element for(var t in Report){ for(var y in Report[t]){ for(var u in Report[t][y]){ HTML('ReportDebug','<span style="position:relative ; border:2px solid black">'+Report[t][y][u]+'</span>',1) // last argument signifies to append HTML element } } HTML('ReportDebug','<br />',1) } } And what I discovered was that whenever I stored values in Selected.Entry the Report array would update with those values! This is my first attempt to create an object in this fashion, so my only guess is that Selected.Entry is not independent from Report[file][entry], but instead some kind of pointer... Where have I gone wrong, and how can I accomplish my goal? Let me know if my code samples were too brief. Hey all, I have a rather complicated program so I'm going to try and make it a little simpler - the problem is with the following function: Code: this.onInsertSuccess = function (paramsArray) { var result = Array(); result[0] = {}; result[0][this.params.idfield] = paramsArray.id; result[0][this.params.titlefield] = "NEW ITEM"; result[0][this.params.displayfield] = 1; console.log(this.displayArray.length); for (x = 0; x < this.displayArray.length; x++) { this.displayArray[x][this.params.displayfield] = x + 2; result[result.length] = this.displayArray[x]; newParams = {idfield:this.params.idfield, id:this.displayArray[x][this.params.idfield], table:this.params.table, displayfield:this.params.displayfield, order:(x+2)}; this.load.updateItem(newParams); } this.displayArray = Array(); for (x = 0; x < result.length; x++) { this.displayArray[x] = result[x]; } this.display(); } Here's a simplified version: Code: onInsertSuccess = function (id) { var result = Array(); result[0] = {}; result[0][this.params.idfield] = id; result[0][this.params.titlefield] = "NEW ITEM"; result[0][this.params.displayfield] = 1; for (x = 0; x < this.displayArray.length; x++) { this.displayArray[x].displayorder = x + 2; result[result.length] = this.displayArray[x]; } this.displayArray = result; // this just updates the display and has no effect on displayArray this.display(); } What's happening is that the first time this is called, displayArray appears to update correctly and a "NEW ITEM" appears at the top of my list. The next time the function is called, displayArray consists of only two results - each "NEW ITEM" - this continues to be the case when the function is called again. the initial displayArray is this: Code: this.displayArray = [{'clid': "1", 'name': "Yorkshire Digital Awards", 'displayorder': "1"}, {'clid': "2", 'name': "Screen Yorkshire", 'displayorder': "2"}, {'clid': "3", 'name': "SureStart Selby District", 'displayorder': "3"}, {'clid': "4", 'name': "Mencap", 'displayorder': "4"}, {'clid': "5", 'name': "York St. Johns", 'displayorder': "5"}, {'clid': "6", 'name': "Mobstar Media", 'displayorder': "6"}, {'clid': "7", 'name': "Wheatfields Hospice", 'displayorder': "7"}, {'clid': "8", 'name': "The National Railway Museum", 'displayorder': "8"}]; I've left the original function in because I fully appreciate that it may be another function that's causing this problem! I thought also it could be to do with accidentally assigning references rather than values (hence the adaption of the result assignment at the end of the function in the full code). Any ideas? Many thanks Edd to see the unexpected page shift in action go to http://lawlocaust.net/gamerverse/ while hovering over the banner u can use the arrow keys to navigate the UI and the page will shift in firefox HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>GamerVerse</title> <link rel="stylesheet" type="text/css" href="<?php echo $domain; ?>gamerverse.css" /> <?php include('children.php'); ?> <script type="text/javascript" src="gamerverse.js"> </script> </head> <?php include('top.php'); ?> top.php Code: <body onload="javascript: initialize()"> <div id="bgimgwrap"> <img id="bgimg" src="<?php echo $domain; ?>mainbg.jpg" alt="" /> </div> <div id="cursor"> </div> <div class="header" id="header" onmouseover="activatekeys()" onmouseout="deactivatekeys()"> <div class="menu"> <ul> <li><a href="#" onclick="javascript: jumpto(0)">Home</a></li> <li><a href="#" onclick="javascript: jumpto(1)">Users</a></li> <li><a href="#" onclick="javascript: jumpto(2)">Games</a></li> <li><a href="#" onclick="javascript: jumpto(3)">New Stuff</a></li> <li><a href="#" onclick="javascript: jumpto(4)">Forum</a></li> <li><a href="#" onclick="javascript: jumpto(5)">Guilds</a></li> <li><a href="#" onclick="javascript: jumpto(6)">Store</a></li> </ul> <div style="float: right; width: 100px;"> X: <span id="myx"> </span> Y: <span id="myy"> </span> </div> </div> <div class="childarea"> <div id="child0"><a href="#" onclick="">child0</a><a href="#" onclick="">child1</a></div> <div id="child1"><a href="#" onclick="">child1</a><a href="#" onclick="">child1</a></div> <div id="child2"><a href="#" onclick="">child2</a><a href="#" onclick="">child1</a></div> <div id="child3"><a href="#" onclick="">child3</a><a href="#" onclick="">child1</a></div> <div id="child4"><a href="#" onclick="">child4</a><a href="#" onclick="">child1</a></div> <div id="child5"><a href="#" onclick="">child5</a><a href="#" onclick="">child1</a></div> <div id="child6"><a href="#" onclick="">child6</a><a href="#" onclick="">child1</a></div> </div> <img src="<?php echo $domain; ?>banner.png" alt="" /> </div> <div class="page" id="page"> <table cellspacing="0px"; cellpadding="0px" id="main"> <tr> <td><div><?php include('home.php'); ?></div></td><td><div><?php include('users.php'); ?></div></td><td><div><?php include('games.php'); ?></div></td><td><div><?php include('new.php'); ?></div></td><td><div><?php include('forum.php'); ?></div></td><td><div><?php include('guilds.php'); ?></div></td><td><div><?php include('store.php'); ?></div></td> </tr> </table> </div> <div id="child"><div id="kid0"><?php echo $homekid; ?></div><div id="kid1"><?php echo $userskid; ?></div><div id="kid2"><?php echo $gameskid; ?></div><div id="kid3"><?php echo $newkid; ?></div><div id="kid4"><?php echo $forumkid; ?></div><div id="kid5"><?php echo $guildskid; ?></div><div id="kid6"><?php echo $storekid; ?></div></div> CSS Code: body { background: black; color: white; width: 100%; height: 100%; overflow: hidden; } * { padding: 0px; margin: 0px; } #bgimgwrap { position: absolute; z-index: 1; top: 0; left: 0; } .header { position: absolute; left: 0; top: 0; width: 100%; z-index: 2; text-align: center; } .menu { width: 100%; text-align: center; margin: auto; padding: 0px 0px 4px 0px; } .menu li { display: inline; margin-left: 0px; float: left; } .menu a { display: block; width: 100px; height: 20px; line-height: 20px; color: white; text-decoration: none; margin-left: 0px; border-bottom: 1px solid white; border-right: 1px solid white; } .menu a:hover { color: black; } .page { position: absolute; left: 0; } #cursor { display: block; position: absolute; top: 0; width: 100px; height: 20px; background: red; opacity:0.4; filter:alpha(opacity=40); z-index: 11; } td { overflow: hidden; background: #6faae4 url(right.png) repeat-y 100% 0%; padding: 0px 25px 0px 25px; } td:before { display: block; content: url(topleft.png); background: url(topright.png) no-repeat 100% 0%; height: 25px; margin: 0px -25px 0px -25px; } td:after { display: block; content: url(bottomleft.png); background: url(bottomright.png) no-repeat 100% 0%; height: 25px; margin: 0px -25px 0px -25px; } td div:first-child { background: #3d74aa; border: 4px outset #c6c6c6; overflow: hidden; } #child { position: absolute; left: 0px; width: 100%; } #kid0 { display: none; } #kid1 { display: none; } #kid2 { display: none; } #kid3 { display: none; } #kid4 { display: none; } #kid5 { display: none; } #kid6 { display: none; } .childarea { width: 100%; height: 20px; margin-top: 17px; } .childarea div { display: none; } .childarea a { display: inline-block; width: 100px; height: 20px; line-height: 20px; color: white; text-decoration: none; margin-left: 0px; border-bottom: 1px solid white; border-right: 1px solid white; } .childarea a:hover { color: black; } #child0 { position: absolute; left: 0px; } #child1 { position: absolute; left: 101px; } #child2 { position: absolute; left: 202px; } #child3 { position: absolute; left: 303px; } #child4 { position: absolute; left: 404px; } #child5 { position: absolute; left: 505px; } #child6 { position: absolute; left: 606px; } javascript Code: //sets the global variables function initialize() { //alert(navigator.appName+' '+navigator.appCodeName+' '+navigator.appVersion); window.bgimg = document.getElementById('bgimg'); window.bgimgwrap = document.getElementById('bgimgwrap'); window.header = document.getElementById('header'); window.page = document.getElementById('page'); window.main = document.getElementById('main'); window.child = document.getElementById('child'); window.cursor = document.getElementById('cursor'); window.childqty = new Array(); window.childqty[0] = 2 - 1; window.childqty[1] = 2 - 1; window.childqty[2] = 2 - 1; window.childqty[3] = 2 - 1; window.childqty[4] = 2 - 1; window.childqty[5] = 2 - 1; window.childqty[6] = 2 - 1; get_dims(); } //adjusts various elements to make the site fluid function get_dims() { winH = getH(); winW = getW(); bgimg.width = header.offsetWidth; bgimg.height = header.offsetHeight; bgimgwrap.width = header.offsetWidth; bgimgwrap.height = header.offsetHeight; var h = header.offsetHeight; page.style.top = h+"px"; main.style.width = (winW*7)+"px"; child.style.top = winH+"px"; child.height = (winH-h)+"px"; var td = document.getElementsByTagName('td'); for(i = 0; i < td.length; i++) { td[i].width = winW+"px"; td[i].style.height = (winH-h)+"px"; td[i].firstChild.style.height = ((winH-h)-58)+"px"; td[i].firstChild.style.width = ((winW - (td[i].firstChild.offsetLeft*2))-8)+"px"; } } //gets the height of the window function getH() { var winH = 0; if (navigator.appName.indexOf("Microsoft")!=-1) { winH = document.documentElement.clientHeight; } else { winH = window.innerHeight; } return winH; } //gets the width of the window function getW() { var winW = 0; if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.documentElement.clientWidth; } else { winW = window.innerWidth; } return winW; } //the keydown action script function move(c) { c = c || window.Event; var k = c.which; if(!k) { var k = c.charCode; } if(!k) { var k = c.keyCode; } var winW = getW(); var winH = getH(); var h = header.offsetHeight; winH = winH - h; switch(k) { case 37: var thing = pos_check(); if(thing == "parent") { if(page.offsetLeft != 0) { slide('right', 0); cursormove('right', 0); } } else { slidekid('right', 0); } break; case 38: var thing = pos_check(); if(thing == "child"){ ditchkids(); } break; case 39: var thing = pos_check(); if(thing == "parent") { if(page.offsetLeft != -(winW*6)) { slide('left', 0); cursormove('left', 0); } } else { slidekid('left', 0); } break; case 40: var thing = pos_check(); if(thing == "parent"){ getkids(); } break; case 116: window.location.reload(); break; default: break; } } //move the page left or right function slide(dir, i) { var w = getW(); if(i < w) { switch(dir) { case 'left': page.style.left = (page.offsetLeft - 8)+"px"; break; case 'right': page.style.left = (page.offsetLeft + 8)+"px"; break; } i++; i++; i++; i++; i++; i++; i++; i++; var t = setTimeout("slide('"+dir+"', '"+i+"')", 0); } if(page.offsetLeft > 0){ page.style.left = 0+"px"; } if(page.offsetLeft < -(w*6)){ page.style.left = -(w*6)+"px"; } } //moves the cursor left or right function cursormove(dir, i) { switch(dir) { case 'left': cursor.style.left = (cursor.offsetLeft + 1)+"px"; break; case 'right': cursor.style.left = (cursor.offsetLeft - 1)+"px"; break; } if(i < 100) { i++; setTimeout("cursormove('"+dir+"', '"+i+"')", 20); } if(cursor.offsetLeft < 0){ cursor.style.left = 0+"px"; } if(cursor.offsetLeft > 606){ cursor.style.left = 606+"px"; } } //checks to see which set of elements ur looking at function pos_check() { var h = header.offsetHeight; if(page.offsetTop == h) { return "parent"; } else { return "child"; } } //displays the child elements function getkids() { var c = cursor.offsetLeft; c = c/101; winW = getW(); p = childqty[c]; document.getElementById(c+'child').style.width = (winW*(p+1))+"px"; document.getElementById('child'+c).style.display = "block"; document.getElementById('kid'+c).style.display = "block"; child.style.left = 0+"px"; raisekid('up', 0); } function raisekid(d, i) { switch(d) { case "up": page.style.top = (page.offsetTop - 2)+"px"; child.style.top = (child.offsetTop - 2)+"px"; break; case "down": page.style.top = (page.offsetTop + 2)+"px"; child.style.top = (child.offsetTop + 2)+"px"; if(i >= page.offsetHeight) { hidekids(); } break; } if(i < page.offsetHeight) { i++; i++; setTimeout("raisekid('"+d+"', '"+i+"')", 0); } if(page.offsetTop > header.offsetHeight){ page.style.top = header.offsetHeight+"px"; } } function ditchkids() { raisekid('down', 0); } function hidekids() { var c = cursor.offsetLeft; c = c/101; document.getElementById('child'+c).style.display = "none"; document.getElementById('kid'+c).style.display = "none"; } //moves the shild pages left or right function slidekid(dir, i) { var w = getW(); if(i < w) { switch(dir) { case 'left': child.style.left = (child.offsetLeft - 8)+"px"; break; case 'right': child.style.left = (child.offsetLeft + 8)+"px"; break; } i++; i++; i++; i++; i++; i++; i++; i++; var t = setTimeout("slidekid('"+dir+"', '"+i+"')", 0); } var c = cursor.offsetLeft; c = c/101; p = childqty[c]; if(child.offsetLeft > 0){ child.style.left = 0+"px"; } if(child.offsetLeft < -(w*p)){ child.style.left = -(w*p)+"px"; } } //turns on the UI when hovering over the banner function activatekeys() { document.addEventListener('keydown', move, true); } //turns off the UI when u stop hovering function deactivatekeys() { document.removeEventListener('keydown', move, true); } I am trying to compare dates to see if they are equal, one date is passed to my function from a calendar. alert(mydate); returns "Tue Dec 22 10:00:00 EST 2009" My date that I need to compare is written dynamically out of a database and it is formatted as a string: 2009-12-22 One might think that (Date(2009-12-22) == mydate) would be true, except the time is also included ... thus it is false, but if I try to use something like this: Code: var dd = new Date(2009-12-22); if(dd.toDateString == mydate.toDateString) ...dostuff ... the dates don't equal ... and I subsequently find out that dd.toDateString actually returns "Fri Jan 22 2010" when I explicitly passed 2009-12-22 to the function. I'd simply like to compare the dates to determine if they are equal so I can pass a return value back to the calendar. The code that works, effectively returning false on all Tuesdays after today is: Code: function disallowDate(d) { var today = new Date(); if (d.getDay() == 2 && (d > today)) return false; return true; } Now I need to determine if any date selected previously is available, so I have to read them out of the database and write them dynamically to the script. Right now I have something like this, but obviously it doesn't work. Code: function disallowDate(d) { var today = new Date(); if (d == Date(2009-12-29)) return true; //this lines is written dynamically if (d == Date(2009-12-22)) return true; //this lines is written dynamically if (d.getDay() == 2 && (d >= today)) return false; return true; } thanks! Hey, this error ONLY occurs in IE. "Unexpected call to method or property access." I pinpointed it to this line: o.appendChild(e); The full function is: Code: function aO(d, t, src, p, id ){ alert('aO has begun.'); var o, e, i; if (!ie){ o = cE('object');o.data = src; } else { o = cE('embed');o.src = src; } o.id = id; if (!ie){ p.push( ['movie', src] ); } if ( typeof(id) === 'String' ){o.id = id;} o.type = t; o.style.width = '210px'; for(i = 0; i < p.length; i++){ e = cE('param'); e.name = p[i][0]; e.value = p[i][1]; o.appendChild(e); } d.appendChild(o); alert('aO has finished.'); } What it does is write a flash object to the page. The FULL code is: Code: <!-- Chat Options --> <noscript> It appears that you do not have JavaScript enabled. Please enable it, otherwise you cannot view the chatbox. </noscript> <div id="chatWrap"> <ul id="ccon" style="display:none;"> <li><a href="javascript:void(0);" onclick="switchChat();">Switch to <span id="cnext">Chat Title</span></a></li> <li><a href="javascript:void(0);" onclick="resizeChat();"><span id="csize">Expand</span> Chat</a></li> <li><a href="javascript:void(0);" onclick="toggleChat();"><span id="chatToggle">Close</span> Chat</a></li> </ul> </div> <div id="cbox" style="display:block;"></div> <!-- Chat Script --> <script type="text/javascript"><!-- // --><![CDATA[ var chats = []; chats[0] = ['Main Chat', 'Uber-Anime-Chat', 1236404792847]; chats[1] = ['Roleplay Chat','Uber-Anime-Roleplay', 1236403501064]; var chat = { 'opt': 'a=000000&b=100&c=999999&d=848484&e=000000&g=CCCCCC&h=333333&i=29&j=CCCCCC&k=666666&l=333333&m=000000&n=CCCCCC&s=1&t=0', 'ref': 'www.uber-anime.com', 'cur': 0, 'delay': 1.5, 'params': [['wmode','transparent'] , ['allowscriptaccess','always'] , ['allownetworking','internal']] } var chatState = 0; var chatStates = []; chatStates[0] = ['Expand', '300px']; chatStates[1] = ['Shrink', '500px']; function cE(e){return document.createElement(e);} function cT(s){return document.createTextNode(s);} var ie = false; function aO(d, t, src, p, id ){ var o, e, i, embed; if (!ie){ o = cE('object');o.data = src; } else { o = cE('embed');o.src = src; } o.id = id; if (!ie){ p.push( ['movie', src] ); } if ( typeof(id) === 'String' ){o.id = id;} o.type = t; o.style.width = '210px'; for(i = 0; i < p.length; i++){ e = cE('param'); e.name = p[i][0]; e.value = p[i][1]; o.appendChild(e); if(ie) { embed = cE('embed'); embed.setAttribute(p[i][0], p[i][1]); } } if(ie) o.appendChild(embed); d.appendChild(o); } function switchChat() { if (document.getElementById('cbox').hasChildNodes()) while (document.getElementById('cbox').childNodes.length >= 1) document.getElementById('cbox').removeChild(document.getElementById('cbox').firstChild); var x = chat.cur; chat.cur = (x + 1) % chats.length; var c = chats[x]; var src = 'http://st.chatango.com/flash/group.swf?ref=' + chat.ref + '&gn=' + c[1] + '.chatango.com&cid=' + c[2] + '&' + chat.opt; document.getElementById('cbox').innerHTML = ''; aO( document.getElementById('cbox'), 'application/x-shockwave-flash', src, chat.params, 'chat' ); document.getElementById('ccon').style.display = 'block'; // qfix document.getElementById('cnext').innerHTML = chats[chat.cur][0]; document.getElementById('chat').style.height = chatStates[chatState][1]; document.getElementById('csize').innerHTML = chatStates[chatState][0]; } function resizeChat(){ if(chatState == 0) chatState = 1; else chatState = 0; document.getElementById('chat').style.height = chatStates[chatState][1]; document.getElementById('csize').innerHTML = chatStates[chatState][0]; } function toggleChat() { if(document.getElementById('cbox').style.display == 'block') { display = 'none'; chatStateTxt = 'Open'; } else { display = 'block'; chatStateTxt = 'Close'; } document.getElementById('chatToggle').innerHTML = chatStateTxt; document.getElementById('cbox').style.display = display; } function chatInit(){ if (navigator.userAgent.indexOf('MSIE') !== -1){ie = true;} if ( chat.delay <= 0 ){ switchChat(); } else { i = cE('img'); i.src = 'ajax-loader.gif'; document.getElementById('cbox').appendChild(i); document.getElementById('cbox').appendChild(cT(' Loading Chat... If this message stays up, your browser may not be supported.')); var clk = setTimeout( function(){ switchChat(); }, chat.delay * 1000 ); } delete chatInit; } chatInit(); //]]> </script> Can anyone tell me how to fix this? This is ridiculously irritating, and it's important that I can fix it ASAP. Hey guys, I've been learning Javascript for a few days using code academy. I've come across this issue, and I'm not sure what exactly I'm doing wrong. Any help would be great. // Check if the user is ready to play! confirm("I am ready to play!"); var age = prompt("What's your age?"); if (age < 13) { console.log("I take no responsiblity, but you are allowed to play") } else { console.log("Have fun!") } console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'") console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'") var userAnswer = prompt("Do you want to race Bieber on stage?"); if userAnswer === "yes" { console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!"); } else { console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'"); } Hi, I'm a newbie to the forum and jquery and have been trying to use it for a slick form wizard i found here. http://thecodemine.org/ It's almost complete but IE keeps giving me an error I've tried everything to fix with no luck. I'm using jquery-1.4.2.min.js and the error it's giving me is Unexpected call to method or property access. line 103 character 460 The code it highlights is: Code: {this.nodeType===1&&this.appendChild(a)})}, at the end of this line. Complete line is: Code: wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, Any help would be greatly appreciated. Thanks! FYI: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Tue, 15 Nov 2011 16:45:53 UTC Message: Unexpected call to method or property access. Line: 103 Char: 460 Code: 0 URI: http://custsatdev/contact/jqueryform...y-1.4.2.min.js I wrote a script that should delete all table rows at once. For loop deletes all rows except row 1 and row 3. Further clicking on the delete button, deletes row 1 and then 3. While loop ,on the first click on the delete button, also leaves rows 1 and 3 not deleted. Further clicking on the delete button, does not delete these rows. I was sure that both version of the script should delete all rows in the table at once. Could someone look at the script and tell me what is wrong? Thank you very much Code: <html> <head> <title>Deleting All Table Entries</title> </head> <script type="text/javascript"> /* WHILE LOOP var i=0; function deleteAll() { document.getElementById("deleteButton").onclick=function() { var table=document.getElementById("myTable"); while(i<table.rows.length) { table.deleteRow(i); i++; } } } */ /*FOR LOOP*/ function deleteAll() { document.getElementById("deleteButton").onclick=function() { var table=document.getElementById("myTable"); for(var i=0; i<table.rows.length; i++) { table.deleteRow(i); } } } window.onload=deleteAll; </script> <body> <table id="myTable"> <tr> <td>Row 0</td> </tr> <tr> <td>Row 1</td> </tr> <tr> <td>Row 2</td> </tr> <tr> <td>Row 3</td> </tr> <tr> <td>Row 4</td> </tr> </table> <button id="deleteButton"> Delete All Rows in the Table </button> </body> </html> this is my javascript code: Code: var aaa, aab; aaa = choo.chooserver0.checked; aab = choo.chooserver1.checked; k=(aaa==true)?0:(aab==true)?1:(aaa=true&&aab==true)? 'b2' : false ; now when the checkbox with id chooserver0 is checked, it sets k's value to 0, and when checkbox with id chooserver1 is checked it sets its value to 1, but when both are checked it must set value to b2, but it sets value to 0, why? and when i write it as: Code: var aaa, aab; aaa = choo.chooserver0.checked; aab = choo.chooserver1.checked; k=(aaa=true&&aab==true)? 'b2' :(aaa==true)?0:(aab==true)?1: false ; when box 1 is checked, it sets k= false, when box2 is checked it sets k= 'b2' and when both are checked it sets k = 'b2'... why is code doing so? |