Page 1 of 1
GOING CRAZY... can't find the error in a few lines of code
Posted: Fri Apr 23, 2010 7:57 am
by maros174
Code: Select all
if (navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1){
$("#pdfPopup img[@src$=png]").pngfix();
$("#pdfPopup .sidebar ul").css({
background: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+urlRoot+"/images/BKGmodelsBox_grad.png', sizingMethod='scale')"
});
}
This is a part of the larger .js code. It fixes .PNG images problem specific to IE6.
Everything works fine in Firefox, Opera, IE6 and Chrome.
The problem appears only in IE7 and IE8.
JavaScript stops executing somewhere after the second line, and the browser reports an error in .js file on that line...
Somebody please help....
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 9:29 am
by maros174
I think this is the problem:
Code: Select all
navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1
IE7 and IE8 just stop loading javascipt after that.
This is something new, everything was working fine until recently - I just noticed it today.
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 9:33 am
by Eran
If you're using jQuery, you might as well use its built in browser detection -
http://api.jquery.com/jQuery.browser/
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 9:36 am
by maros174
I'm not that good in this... That is way beyond my level of expertise...
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 9:50 am
by pickle
+1
In addition, install the developer tools for IE8 - it can give you more useful javascript errors.
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 9:56 am
by maros174
I looked elsewhere on the site. Other page that uses same solution to IE6 transparency problem also stopped working.
First it reported an error (on line 136), here on the first two lines:
Code: Select all
function ie6PngFix(){
$(".content img[@src$=png]").pngfix();
$(".sidebar ul").css({
background: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+urlRoot+"/images/BKGmodelsBox_grad.png', sizingMethod='scale')"
});
When I commented that part of the code it reported an error (on line 71), here on the second line:
Code: Select all
$(document).ready(function() {
if (navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1){ ie6PngFix(); }
if (navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1){ ie6HoverFix(); }
else { over_hover(".sidebar ul li"); }
slideFeatures();
modelFormPopupCheck(".modelsButt");
$("#modelsNav li").click(function(){
if ($(this).is(".on") || $(".modelContent").is(":animated") ) { return false; }
$("#modelsNav li").removeClass("on");
$(this).addClass("on");
switchModelsContents($(this).prevAll().length)
});
});
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 12:15 pm
by maros174
...
Ok, I've isolated the problem.
IE7 and IE8 report an error on this line in the function below:
$(".content img[@src$=png]").pngfix();
Code: Select all
function ie6PngFix(){
$(".content img[@src$=png]").pngfix();
$(".sidebar ul").css({
background: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+urlRoot+"/images/BKGmodelsBox_grad.png', sizingMethod='scale')"
});
and on the other page, this line is the problem
Code: Select all
if (navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1){ ie6PngFix(); }
In both cases, JavaScript on the page doesn't work at all and IE reports:
ERROR: Object doesn't support this property or method
Everything works fine when I remove those lines... only the transparent PNG's in IE6 are broken... and I need them badly.
What troubles me that everything was working fine for a year and then a couple of days ago suddenly this hell broke loose...
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 12:17 pm
by pickle
Use. JQuery's. Built. In. Browser. Detection.
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 1:08 pm
by maros174
pickle wrote:Use. JQuery's. Built. In. Browser. Detection.
Tried...it doesn't solve the problem.
Code: Select all
if ($.browser.msie && $.browser.version.substr(0,1)<7){
$("#pdfPopup img[@src$=png]").pngfix();
$("#pdfPopup .sidebar ul").css({
background: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+urlRoot+"/images/BKGmodelsBox_grad.png', sizingMethod='scale')"
});
}
This works in IE7 and IE8 (problem line commented)... no error and JavaScript loads fine.
But I need transparent PNG's in IE6 badly... and this solution turns that functionality off (it worked for a year, until a couple of day ago...)
Code: Select all
if (navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1){
//$("#pdfPopup img[@src$=png]").pngfix();
$("#pdfPopup .sidebar ul").css({
background: "none",
filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+urlRoot+"/images/BKGmodelsBox_grad.png', sizingMethod='scale')"
});
}
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 3:58 pm
by Eran
A couple of things:
1. check the values to see they return what you expect (debugging 101)
Code: Select all
alert($.browser.msie);
alert($.browser.version.substr(0,1)<7);
2. You can also use IE6 css rules to apply the transparency filter instead of using javascript. I'd consider this alternative as it's better all around (works without javascript, better performance, etc)
Re: GOING CRAZY... can't find the error in a few lines of co
Posted: Fri Apr 23, 2010 4:17 pm
by Benjamin
I would check the ID's for all the elements on the page. IE has issues with names that may be used elsewhere, such as id="form" etc. So that is where I would start.