JavaScript - Jquery - Firebug Gives An Error/warning!
Hello.
I'm coding a simple hover-opacity thing for some images on my site on the navigation bar. Although I'm receiving this message in my Firebug. uncaught exception: Syntax error, unrecognized expression: . Here's the navigation code: Code: <div class="navigation"> <a href="home"><img class="home" src="images/navigation/home.gif" /></a> - <a href="home" class="home">Home</a> <a href="news"><img class="news" src="images/navigation/news.gif" /></a> - <a href="news" class="news">News</a> </div> So the effect I've made is, when I hover the image, its opacity gets set to 1. And when I move my mouse away the image changes opacity to .5 And when I hover the text "Home" or "News" the same effect happens with the image. And here's my jQuery: Code: $(function(){ $('.navigation img').css({ opacity: .5 }); $('.navigation img').hover(function(){ $(this).stop().animate({ opacity: 1 },300); }, function(){ $(this).stop().animate({ opacity: .5 },300); }); $('.navigation a').hover(function(){ var imageClass = $(this).attr('class'); $('.navigation img.' + imageClass).stop().animate({ opacity: 1 }, 300); }, function(){ var imageClass = $(this).attr('class'); $('.navigation img.' + imageClass).stop().animate({ opacity: .5 }, 300); }); }); I can't seem to find the error in my script(s). Any help is appreciated. EDIT: Apparently the error appears when I make anchor tags around the image. Code: <a href="home"><img ... /></a> This gives the error. :S Code: <img ... /> But this doesn't? How can this be? Similar Tutorials<!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" lang="en" xml:lang="en" > <title>Assignment 4 - JavaScript Conditional Variables</title> <head> <script type="text/javascript"> alert("Browser"+"\n\n"+navigator.appName); student = confirm("Are you student at Silicon ?"); if(student==true){ alert("please enter your marks"); } else{ alert("please register first"); location.href="Registration.html"; } function getGrade(){ if((Number(document.form1.input1.value)>90) && (Number(document.form1.input1.value)<100)) { alert("Grade A"); } else if((Number(document.form1.input1.value)>80) && (Number(document.form1.input1.value)<90)) { alert("Grade B"); } else if((Number(document.form1.input1.value)>70) && (Number(document.form1.input1.value)<80)) { alert("Grade C"); } else if((Number(document.form1.input1.value)>60) && (Number(document.form1.input1.value)<70)) { alert("Grade D"); } else if((Number(document.form1.input1.value)>50) && (Number(document.form1.input1.value)<60)) { alert("Grade F"); } else if(Number(document.form1.input1.value)<50) { alert("Grade G"); } } function identifyKey(evt){ evt = evt || window.event; if(navigator.appName==/*Internet Explorer*/){ var charCode = evt.keyCode; } else{ var charCode = evt.which; } alert(charCode); } </script> <style type="text/css"> #main{ margin:auto; width:70%; } #top{ font-size:20px; font-weight:bolder; color:#007700; text-decoration:underline; } #s1{ font-size:20px; font-weight:bold; color:#7700ff; } #s2{ font-size:20px; font-weight:bold; color:#00ff00; } #s3{ font-size:20px; font-weight:bold; color:#ff0000; } #form1{ width:600px; height:80px; padding:20px; background-color:#aaaaaa; } </style> </head> <body> <div id="main"> <p id="top">Assignment 4 - JavaScript Conditional Variables</p> <span id=s1>This is Form for checking Grade</span> <form id=form1 name=form1> <table> <tr><td>Enter Marks </td><td>: <input type="text" name="input1" onkeypress=identifyKey(event) /></td></tr> <tr><td><input type="button" name=btn1 value="Get Grade" onclick=getGrade() /></td></tr> </table> </form> </div> </body> </html> When I try to check whats wrong with this script in Firebug, I get error Quote: No Javascript on this page If <script> tags have a "type" attribute it should equal "text/javascript" or "application/javascript" Why am I getting such an error in Firebug. I understand there is some syntax error in this script How can I check whats wrong if I am getting such a message in Firebug ? Thanks Hello. Recently my company's site has been acting funny. Images on the page bladv.com/work aren't displaying except in older/non-updated browsers. When I ran Firebug to check the javascript, I got the following message twice. "NetworkError: 404 Not Found - http://bladv.com/assets/_cache/00000000009939b9184d06e0feb33450dc78b54e11.js" Does anyone know why I'm getting this code, and would this be the reason images on the page bladv.com/work aren't showing up? If this is the problem, how do I fix it? I tried adding the js file into the cache folder but I'm still getting the error codes in Firebug and the images are still invisible. Hope that makes sense, I'm very very new to javascript. Thanks I'm getting an '$active is not defined' error, which makes sense because the method that defines it isn't called till 10 seconds after I check if it is defined below. But that's the point. I'm actually checking to see if it is defined, and if it's not, then I defined. However, firebug still gives me the error for this: Code: if ($active == undefined) { $active = $('.paging a.active'); } var triggerID = $active.attr("rel") - 1; var image_reelPosition = triggerID * imageWidth; I also tried: if ($active === undefined) if (!$active) But nothing works. I'm just trying to check if it's not defined, then define it. Yet it won't let me check if it is undefined because it is telling me it's undefined despite the fact I'm checking for that very reason. Thanks for any response. Greetings all. Please let me apologize in advance if this is a tremendously stupid question, but I'm new to Jquery and ASP... and I'm suddenly building an entire site made of both. *sigh* I keep getting an error message in Firebug in relation to the accordion menu I created. "$ not defined $(function() {" If the navigation is isolated on its own page, the error does not exist. It only occurs once it is brought into the Store Master page. Working Version: http://www.stephenjosephinc.com/testing/ Non-Working Version: http://74.124.26.78/ The following code is cut from the head in the non-functional page: Code: <head id="ctl00_Head1"> <title>Shop Online</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="icon" href="App_Master/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="App_Master/favicon.ico" type="image/x-icon" /> <link type="text/css" href="App_Master/css/custom-theme/jquery-ui-1.8.4.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.4.custom.min.js"></script> <link type="text/css" href="App_Master/theme/ui.all.css" media="screen" rel="stylesheet" /> <script type="text/javascript"> $(function() { $("#accordion").accordion({ collapsible: true, autoHeight: false, header: "h3"} ); }); </script> <link href="App_Themes/DefaultTheme/master.css" type="text/css" rel="stylesheet" /> <link href="App_Themes/DefaultTheme/menu.css" type="text/css" rel="stylesheet" /> </head> If it helps at all, you may view the entire code he http://74.124.26.78/full_code.txt Please note: I DID NOT create the code on the aforementioned page. It's an ugly, nightmarish mess (at least to my non-ASP-loving eyes), so please don't hate me for bad form in the body code. The only code that I wrote for this page is the bit you see above and the hrefs for the side nav. Any help would be massively appreciated! Thank you in advance! On my wordpress based website, I have jquery for the top button selection part on the homepage, and lightbox for the gallery, and they work fine. But when I enter the url with a GET (.com?something), they don't work. I can't figure out if it is a jQuery error, or jQuery with wordpress's url structure. Ex: http://www.naturallookinstitute.com/gallery/ - OK http://www.naturallookinstitute.com/gallery?get - Lightbox broken http://www.naturallookinstitute.com/ - OK http://www.naturallookinstitute.com?get - Top header selector broken Hi all. I am using the Inline Form Validation Engine jQuery plugin found here, and though I have posted at their forum as well, am having a heck of a time (not being well versed in js OR Ajax, unfortunately) All I need to do is edit the code so that when the onSubmit function is processed, it returns only the first error it encounters, rather than keeping and display the array of every error. I have picked through the code several times, and can't seem to find where the array is stored. I thought perhaps I could find a for loop to limit, but am at a complete loss. Is there anyone out there who can help? I can post the code if needed; I didn't want to post the entire file (since I don't know which snippet is the one I need!) Thank you in advance! Hello, I am trying to add a simple script to my CSS menu for a little bit more eye candy. However, when I add the script - it causes issues in my online store (ex; the javascript-powered one page checkout stops working). Here is the exact error from the error console: Quote: Error: jQuery.validator is undefined Source File: https://www.gem-tech.com/store/pc/onepagecheckout.asp Line: 288 And here is the exact script: Quote: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript" src="jquery.hoverIntent.minified.js"></script> <script type="text/javascript"> $(document).ready(function() { function megaHoverOver(){ $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Calculate width of all ul's (function($) { jQuery.fn.calcSubWidth = function() { rowWidth = 0; //Calculate row $(this).find("ul").each(function() { rowWidth += $(this).width(); }); }; })(jQuery); if ( $(this).find(".row").length > 0 ) { //If row exists... var biggestRow = 0; //Calculate each row $(this).find(".row").each(function() { $(this).calcSubWidth(); //Find biggest row if(rowWidth > biggestRow) { biggestRow = rowWidth; } }); //Set width $(this).find(".sub").css({'width' :biggestRow}); $(this).find(".row:last").css({'margin':'0'}); } else { //If row does not exist... $(this).calcSubWidth(); //Set Width $(this).find(".sub").css({'width' : rowWidth}); } } function megaHoverOut(){ $(this).find(".sub").stop().fadeTo('fast', 0, function() { $(this).hide(); }); } var config = { sensitivity: 2, // number = sensitivity threshold (must be 1 or higher) interval: 100, // number = milliseconds for onMouseOver polling interval over: megaHoverOver, // function = onMouseOver callback (REQUIRED) timeout: 500, // number = milliseconds delay before onMouseOut out: megaHoverOut // function = onMouseOut callback (REQUIRED) }; $("ul#topnav li .sub").css({'opacity':'0'}); $("ul#topnav li").hoverIntent(config); }); </script> I believe there is some sort of conflict? Not sure though. Any input on this? Thanks, I am trying to debug this with FireBug Code: function chapter12_nodeOne() { //create an element var element = document.createElement('input'); //set some attributes element.setAttribute('type', 'button'); element.setAttribute('value', 'submit'); //appendd the element into a DIV document.getElementById('myDiv').appendChild(element); //uses EventUtil to attach an event listener (1) EventUtil.addHandler(element, 'click', function() { alert('added event handler') }); } var EventUtil = { (2)addHandler: function(element, type, handler) { //check if the element and the browser support DOM Level 2 event attachment //if the user is not browsing with IE if (element.addEventListener) { element.addEventListener(type, handler, false); } //if user is browsing with IE else if (element.attachEvent) { element.attachEvent("on" + type, handler); } //if user is using a browser that only supports DOM Level 0 event attachment else { element["on" + type] = handler; } }, removeHandler: function(element, type, handler) { //check if the element and the browser support DOM Level 2 event attachment //if the user is not browsing with IE if (element.removeEventListener) { element.removeEventListener(type, handler, false); } //if user is browsing with IE else if (element.detachEvent) { element.detachEvent("on" + type, handler); } //if user is using a browser that only supports DOM Level 0 event attachment else { element["on" + type] = null; } }, preventDefault: function(event) { if(event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } }; I put a breakpoint on the line marked with (1), I am trying to go to line (2) with all the available options FireBug gives, but unfortunately I get the end of chapter12_nodeOne function. Any ideas why? Hi, I have an image slider that uses the: jquery.min.js file this basically slides up and down smoothly when clicked. I then added a Jquery accordian menu. When I put the 2 together the menu doesn't work it just stays fully expanded. As soon as I remove jquery.min.js it works fine but then the slider doesn't. What could this be please? Thanks alot Joe Hey all, Whenever firebug detects a js error on a page, it prevents you from interacting with the page, so you can't scroll, you can't click, you can't do anything except close the window. Anyway around this? Thanks. Hey all, Firebug gives me the below error message: component.singularize is not a function [Break on this error] var component = component.singularize(); This is what I have: Code: var component = window.location.hash.replace('#', ''); var component = component.singularize(); alert("The component name is " + component); var singularize = function(){ if(!String.prototype.singularize){ String.prototype.singularize = function(){ var context = this; result = ((context.charAt(context.length -1, 1) == 's') ? context.substring(0, context.length - 1) : context); return result; } } } Thanks for any response. Hi Friends, I am come with a new query in jQuery. I have a listing form in which the details showed , the View more Details is implemented using Ajax. When Click "+" sign there is a loading image show First then the Result show there ... It's all working Fine , But I need a way to show Error I mean some time Server Response is success with Empty String on that time I need to catch same .... I explain code Below: Code: if(proceed) { $.ajax({ type: "POST", data: "key="+id, dataType: 'json', async: true, url: "<?php echo site_url(); ?>/server/view_serverdet/", beforeSend: function() { $('#view_load'+id).show(); $('#view_load'+id).addClass(class); }, complete: function(){ $('#view_load'+id).hide(); } }, success: function (server_msg) { if (null == server_msg) { var warning = "<font color=\"red\">Unable to load server details</font>"; $('#view_load'+id).html(warning); } else { // Working Fine! } But that error Just Show and Hide ... How I can show that Error there, If you have any idea , pls help me ASAP... Thankfully Anes P.A 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, on my site, http://www.jbiddulph.com/john-drag.html when i move the box within the box, the results are only shown when I click on the firebug icon?! Can someone please help me here? I would like the results to be shown OnMouseUP thanks Hi, I have this web browser which opens up a website that has a drop down list showing values that the user can select. And when I the firebug to inspect the elements in the page, what shows in the inspection window is this: Code: <select id="instance2" name="instance2"> <option value="0">All instances</option> <option value="1">Item0</option> <option value="2">Item1</option> <option value="3">Item2</option> . . . <option value="23">Item22</option> What I'm supposed to do is to get the values and update them automatically to the database. I'm actually using HtmlUnit to do this project, and I've heard how I can use getElementById() to get the values. But I don't know how to start. I'm a beginner so I might need a lot of help on this matter. Help is kindly appreciated. Thanks. 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 Hello JavaScripters! I was hoping you could help me with an application I'm working on using C# and the .NET Framework that incorporates Javascript. I'm trying to do something similar to to the FireBug / Firefox Inspect Element featu I came across http://www.selectorgadget.com/ which is exactly what I'm trying to do. It's in Javascript and after looking through the source code for the past 2 hours I still don't have a clue how to incorporate it into my program... From what I can tell it uses tokenizing and recursive analysis of DOM elements to figure out CSS selector paths: http://www.selectorgadget.com/stable/lib/dom.js. Here is what I have so far. The javascript code highlights HTML elements such as a <table> tag and changes the border and background color. Code: document.onmouseover = dohighlight; document.onmouseout = dohighlightoff; var BGCOLOR = "#444444"; var BORDERCOLOR = "#FF0000"; // Highlight <table> in grey function dohighlight() { var elem = window.event.srcElement; while (elem!=null && elem.tagName!="TABLE") elem = elem.parentElement; if (elem==null) return; if (elem.border==0) { elem.border = 1; // store current values in custom tag attributes // elem.oldcolor = elem.style.backgroundColor; // store backgroundcolor elem.style.backgroundColor = BGCOLOR; // new background color elem.oldbordercolor = elem.style.borderColor; // same with bordercolor elem.style.borderColor = BORDERCOLOR; var rng = document.body.createTextRange(); rng.moveToElementText(elem); // Make a red border around <table> function dohighlightoff() { var elem = window.event.srcElement; while (elem!=null && elem.tagName!="TABLE") elem = elem.parentElement; if (elem==null) return; if (elem.border==1) { elem.border = 0; // recover values from custom tag attribute values elem.style.backgroundColor = elem.oldcolor; elem.style.borderColor = elem.oldbordercolor; } } Any ideas on how to incorporate the Selectorgadget into my program would be greatly appreciated! Selectorgadget Source Code: https://github.com/iterationlabs/selectorgadget <!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" lang="en" xml:lang="en" > <title>Assignment 5 - JavaScript Loops</title> <head> <script type="text/javascript"> function getGrade(){ var i= Number(document.getElementById("input1").value); m=Math.floor(i/2); for(var k=1; k<=i; k++){ for(var j=1; j<=k; j++){ document.write(j+" "); if(j==k){ document.write("\n"); } if(j==i){ decreaseLoop(j, k); } } } function decreaseLoop(j, k){ for(k=k-1; k>0; k--){ for(var l=1; l<=k; l++){ document.write(l+" "); if(l==k){ document.write("\n"); } } } } } </script> <style type="text/css"> #main{ margin:auto; width:70%; } #top{ font-size:20px; font-weight:bolder; color:#007700; text-decoration:underline; } #s1{ font-size:20px; font-weight:bold; color:#7700ff; } #s2{ font-size:20px; font-weight:bold; color:#00ff00; } #s3{ font-size:20px; font-weight:bold; color:#ff0000; } #form1{ width:600px; height:80px; padding:20px; background-color:#aaaaaa; } </style> </head> <body> <div id="main"> <p id="top">Assignment 5 - JavaScript Loops</p> <span id=s1>This is Form for checking Loop</span> <form id=form1 name=form1> <table> <tr><td>Enter Number </td><td>: <input type="text" id=input1 name="input1" /></td></tr> <tr><td><input type="button" name=btn1 value="Get Number" onclick=getGrade() /></td></tr> </table> </form> </div> </body> </html> When I execute this code, on the screen I see all output in one line. Which is not hat I want. But when I see it in Firebug (for firefox)or Developer Tool Bar(for IE) , I see it printed out in pyramid form(as required). So why is this output in one line on screen ? How cn I get it in pyramid form ? Thanks Hey all, For the below code, I'm just trying to create a simple toggle menu for a Table of Contents. However, when page loads, I get document.gelementbyid('sidebar') is null even though it's clearly there and if I move script to below markup, it will also give me a hideElements() is not a function error, even though it clearly is. Code: <script type="text/javascript"> (function(){ var headers = document.getElementById("sidebar").childNodes; for(var i=0; i < headers.length; i++){ hideElements(headers[i]); if(headers[i].nodeName == "h1"){ headers[i].childNodes[0].onclick = function(){ hideElements(headers[i]); this.parentNode.nextSibling.style.display = "block"; return false; } } } var hideElements = function(element){ if(element.nodeName == "UL") element.style.display = "none"; } })(); </script> <body> <a name="top"></a> <div id="masthead"> <h1>This is the Help Page</h1> </div> <div id="sidebar"> <h1><a href="chapter1"> Info</a></h1> <ul> <li><a href="#section1">Section 1</a></li> <li><a href="#section2">Section 2</a></li> <li><a href="#section3">Section 3</a></li> </ul> <h1><a href="chapter2"> Info</a></h1> <ul> <li><a href="#section4">Section 4</a></li> <li><a href="#section5">Section 5</a></li> <li><a href="#section6">Section 6</a></li> </ul> </div> <div id="content"> <h1 id="section1">Section 1</h1> <p> </p> <a href="#top">Back to Top</a> <h1 id="section2">Section 2</h1> <p> </p> <a href="#top">Back to Top</a> <h1 id="section3">Section 3</h1> <p> </p> <a href="#top">Back to Top</a> </div> </body> Thanks for any response. So, i have this code which retrieves php files for me using jquery and id love to get it working with Jquery history plugin. I tried modifying the code i got from the ajax demo to work for me, but i just couldnt do it as i do not know any javascript really.. ( actually what i tried was simply to change "#ajax-links a" to "#menu li a" and .html to .php ..but nothing.. :rolleyes: Id be very gratefull if someone would help me out with this one. All related code can be found bellow (the ones that should be needed anyways): This is the code that retrieves php files inside "#content" when item from "#menu li a" with the specified id is clicked Code: $(document).ready(function(){ //References var change = $("#menu li a"); var loading = $("#loading"); var content = $("#content"); //Manage click events change.click(function(){ //show the loading bar showLoading(); //load selected section if(this.id == "home") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/index.php", hideLoading); content.slideDown(); } else if(this.id == "secondpage") { change.load(this.className='current-page'); content.slideUp(); content.load("pages/secondpage.php", hideLoading); content.slideDown(); } else { //hide loading bar if there is no selected section hideLoading(); } }); //show loading bar function showLoading(){ loading .css({visibility:"visible"}) .css({opacity:"1"}) .css({display:"block"}) ; } //hide loading bar function hideLoading(){ loading.fadeTo(1000, 0); }; }); Heres the structure of the menu/content Code: <ul id="menu"> <li><a id="home" class="normal" href="#Home"></a></li> <li><a id="secondpage" class="normal" href="#Secondpage"></a></li> </ul> <div id="content"> <ul id="sec-menu"> <li><a id="link1" class="normal" href="#">Link1</a></li> <li><a id="link2" class="normal" href="#">Link2</a></li> </ul> </div> Heres the code that jquery history plugin uses in demo for ajax Code: jQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); |