internet explorer - JQuery Text Resizing not working with IE -
i using following script (that requires cookies plugin jquery) allow javascript enabled users change font size on medical charity website:
var sitefunctions = { textresize: function () { var $cookie_name = "textsize"; var originalfontsize = $("html").css("font-size"); // if exists load saved value, otherwise store if ($.cookie($cookie_name)) { var $getsize = $.cookie($cookie_name); $("html").css({ fontsize: $getsize + ($getsize.indexof("px") != -1 ? "" : "px") }); // ie fix double "pxpx" error } else { $.cookie($cookie_name, originalfontsize); } // reset link $(".reset").bind("click", function () { $("html").css({ "font-size": originalfontsize }); $.cookie($cookie_name, originalfontsize); }); // text "+" link $(".increase").bind("click", function () { var currentfontsize = $("html").css("font-size"); var currentfontsizenum = parsefloat(currentfontsize, 10); var newfontsize = currentfontsizenum * 1.2; if (newfontsize, 11) { $("html").css({ "font-size": newfontsize }); $.cookie($cookie_name, newfontsize); } return false; }); $(".decrease").bind("click", function () { var currentfontsize = $("html").css("font-size"); var currentfontsizenum = parsefloat(currentfontsize, 10); var newfontsize = currentfontsizenum / 1.2; if (newfontsize, 11) { $("html").css({ "font-size": newfontsize }); $.cookie($cookie_name, newfontsize); } return false; }); } }
you can call page so:
$(document).ready(function () { // show text resizing links $(".accessibilitycontrols").show(); sitefunctions.textresize(); })
you can put links in page so:
<div class="accessibilitycontrols" style="display:none;"> text size:<br /> <a class="increasefont" style="font-size: 14pt;" title="increase text size" href="#" rel="nofollow">a+</a> | <a class="decreasefont" style="font-size: 11pt;" title="decrease text size" href="#" rel="nofollow">a-</a> | <a class="resetfont" href="#" rel="nofollow">reset </a> </div>
so far, good. above presuposes have set font-size in style sheet html tag follows:
html { font-size: x-small; }
problem 1:
it works fine browsers except ie.
why?!
problem 2:
i fine debugging in firefox, ie problem! have tried attaching process vs debugger, seems work intermitently...
ok, quick , instructive.
asking question half answer...
ie not able interpret x-small numerical size, mozilla browsers do.
as script using tries attach px font-size property, end with:
x-smallpx
whereupon jquery tells naff off.
changing to:
html { font-size:65%; }
solved issue. evaluated number ie , jquery happy.
i still confused visual studio , js debugging. there seem many ways skin cat , none work time.
having first encountered problem yesterday, relieved have solved , have found how debug in ie. double whammy.
the problem left have read somewhere desirable use x-small set font-size , make other sizes relative that. left feeling bit naked font-size:65% malarkey...
still, have work around accessiblity issues issue.
Comments
Post a Comment