I am receiving the following error in IE which is stopping the page from loading. I have tried to find this error but for the life of me cannot see it. The portion of the code that the error points to is here at jsfiddle.net:
http://jsfiddle.net/SrgsC/
I would be grateful if someone could point out the offending error? Many thanks
I am using php5.3.5
Message: Expected ')'
Line: 2867
Char: 41
Code: 0
URI: http://sample.com/admin/cp.php
Message: Expected ')'
Line: 2867
Char: 40
Code: 0
URI: http://sample.com/admin/cp.php
Well, the code you provided is in PHP, not JavaScript. If this is only happening in IE, then it is clear that you have put a PHP function in a JavaScript file. Otherwise, it should be happening in IE, FF, Chrome...
Some issues with the PHP function at any rate:
you start with $print .= . This means, "add the following string to the $print" variable, but $print is not defined in that function. If it is a global variable, you need to put global $print; on the line before it, or, if it is local, then you need to use $print = (no '.')
mysql_numrows should be mysql_num_rows unless you've created your own numrows function
mysql_result should not be used that way. To quote the docs:
When working on large result sets, you should consider using one of the functions that fetch an entire row
You should not be manually iterating through rows by tracking the current row number (the same reason as above)
A 15 parameter function is too many. It is way to many. The maximum which can be handled effectively are 7 (according to Code Complete), the more zealous would argue for even fewer (Uncle Bob, I believe, says 3 is a good standard). Either way, if I saw 8 or more parameters in a method during a code review I would immediately know something needed to change.
Related
I'm trying to create code that requires the least number of bytes and that works for all browsers including IE 7.
In this example, the program calls dosomething('x1') and dosomething('x2').
If I have code like this:
var items,item,index,count;
items=Array('x1','x2');
count=items.length;
for (index=0;index<count;index++){
item=items[index];
dosomething(item);
}
Could I reduce it to this and have it still function exactly the same in all browsers:
var a=Array('x1','x2'),c=a.length,i;
for (i=0;i<c;i++){
f(a[i]);
}
I understand I changed the variable names and calling function name but my goal is to use the least number of bytes possible in the code to make the code execute.
I'm just not sure if declaring a variable equal to a property of a value from a previous variable in the same list of declarations would actually return correct results.
In other words, does var a=Array('x1','x2'),c=a.length... work, or do I have to specifically do var a=Array('x1','x2');var c=a.length; to make it work in all browsers including IE 7?
This is what the Google Closure Compiler service returned:
var a,b,c,d;a=["x1","x2"];d=a.length;for(c=0;c<d;c++)b=a[c],dosomething(b);
You can find many different Javascript compressors online to automate the process you are hand coding now. Yet, it's always good to understand how they work as it helps to write code that is better compressed.
As for IE, you can test your code by changing the emulations settings in the IE debugger panel. Just press F12, click the Emulation tab, and adjust the document mode to 7 (IE7).
Hope this is enough to get you started in the right direction.
You can use Array.map from IE 9
var items = Array('x1','x2');
items.map(dosomething(item));
I was trying to make a slide show gallery and used the example at URL - http://mediaeventservices.com/2007/11/15/ajax-image-gallery-powered-by-slideflow-like-cover-flow/
When I view it in FF it works fine however IE and chrome give me an error:
“is null or not an object”.
Message: Object required
Line: 66
Char: 2
Code: 0
URI: file:///C:/Romona/P%20drive%20backup/componets/slideShow/slideShow4/slideShowGallery/gallery.html
IE developer tools indicate that the below line is causing the problem:
var imgSrc = ‘photos/large/’+ photos.item(photoNumber – 1).getElementsByTagName(“src”)[0].childNodes[0].nodeValue;
Does anyone have any suggestions?
Thank you
First of all, i hope your real code doesn't have smart quotes “src” and has dumb quotes instead "src".
Second, getElementsByTagName("src") isn't going to work. That will find <src> tags. But you probably want <img> tags instead, so search for "img" instead.
I think getElementsByTagName("src") returns an empty array because nothing is found, getting the first item with [0] returns null, and calling childNodes on null raises this error.
At the very least, try breaking that line up and see what steps return something you don't expect.
I am using JQuery min 1.4.2. I have a function which iterates through a few tables and adds a class with a number attached:
$("#reportArea table", this).each(function(i){
$(this).addClass("table-" + i);
});
For some reason this throws an error in IE 8 and IE9, however, in Firefox and Chrome when I open console, I do not see any errors. The error in IE is:
Message: Invalid argument.
Line: 48
Char: 1
Code: 0
URI: /js/jquery-min.js
If I look at line 48 in the IE debugger, I see this:
a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue; etc..
I also tried rephrasing my code to this but still get the same error:
$('#reportArea table:eq(0)').addClass('table-0');
$('#reportArea table:eq(1)').addClass('table-1');
The odd part is that the class still gets added to the tables in IE.
Note, I would add the classes manually but it's a JSP Report page and I don't have access to the specific template that controls this page.
$("#reportArea table", this).each(...
^^^^
What is this in here? It should be a DOM context. I don't think you need it for your selector as ids are (should be) unique. If you're not calling that function inside a specific function, the this keyword might reference the global object and therefore cause the error.
This music site shows the dreamweaver function MM_timelinePlay as undefined in chrome and firebug, but it is clearly defined in the header. The header is pulled in dynamically, but this should not matter as it has loaded by the time triggers it. The function is called on the hover state of a button labeled "more."
The code on line 62 is the following (within the function body for MM_initTimelines ):
px", "4px");
This is triggering a JavaScript error when the JS is being parsed, which seeing as the MM_timelinePlay is after the parse error, that function is not actually available to the page for use. Not sure what is supposed to be on line 62, but it appears that the line got munched somewhere in the process (perhaps as part of a bad copy and paste, or as part of at bad edit).
You may be able to recover the line by using the else branch of the if statement that line 62 is part of, here it is:
document.MM_Time[0][0].values[0] = new Array(-141,-131,-120,-110,-100,-89,-79,-69,-58,-48,-37,-27,-17,-6,4);
Change line 62 to something like the following:
document.MM_Time[0][0].values[0] = new Array("-141px","-131px","-120px","-110px","-100px","-89px","-79px","-69px","-58px","-48px","-37px","-27px","-17px","-6px","4px");
Make sure it's all on one line. The edits made were to simply wrap each value of the array with " and then include px. Based on searches for the MM_initTimelines function, the matching line of code (which differs based on the specific movements defined, the true branch of the if statement in your code should match the else except that the values are strings with the px unit added.
As timelines are no longer part of Dreamweaver (removed as of CS5 I think, but maybe earilier), you won't be able to restore or edit the timelines if you are using a newer version of Dreamweaver, so keep the old one around.
I am pulling my hairs out over an invalid argument error in IE7, maybe all IE's...
The site is: http://www.karencaldwelldesign.com/fashion
IE says it is an error on line 12, but if I open up Script Debugger it says the problem is with some code in jQuery. I don't buy that.
So, I looked at my script (http://www.caldwellsnyder.com/__data/assets/js_file/0003/5943/kc-gallery.js) and line 65 seems to be the problem:
data = '<div id="content'+id+'" class="content">'+data+'</div>';
data is returned from the jQuery $.ajax() function, but I needed to wrap it with an additional numbered div.
In particular it is the id variable that is caused the invalid argument error, but I have no idea why! The var is just a number that gets incremented. Removing the var from that line lets the page load perfectly, but I really need to increment the id in this way.
Does anyone have any idea why this simple variable would be cause invalid argument in IE?
Somehow you're ending up trying to set a width of -5px; IE doesn't like that. That value is coming from the line $this.css(cssToApply); in JScrollPane.js which gets it from calculating the variable realPaneWidth:
var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;
In that, paneWidth and settings.scrollbarWidth both equal 676, and settings.scrollbarMargin is 5, giving you -5 (p is zero).
In kc-gallery.js you appear to be initialising jScrollPane with the value of 676 for scrollbarWidth in the function applyScroll. This is called from the setInterval function assigned to the variable check_images, and that takes us all the way back up the call stack from the place where IE actually errors on setting width to -5px.
So it's definitely something to do with the way you're using JScrollPane. You may want to check the documentation for any tips - I've never used that plugin myself, so I'm afraid I can't help with that. However, a scrollbarWidth value of 676 seems a little excessive... according to the JScrollPane docs:
scrollbarWidth [int] - the width of the created scrollbar in pixels (defaults to 10)
The error you are seeing comes from jQuery when you try to set a DOM attribute to a value that is invalid. For example try setting a z-index to NaN or a string. IE errors on this where firefox and other browsers just ignore the value.
You can see an example of this by dropping the following line in to the console on this page in IE8 or using Jash for earlier versions: jQuery("#header").css("z-index", NaN);
It looks like your variable glob_index is becoming undefined at some point, thus jQuery errors when trying to set the z-index of a DOM node to this.