Reputation: 751
I have this jjavascript to resize iframes:
$(function () {
var iFrames = $('iframe');
function iResize() {
for (var i = 0, j = iFrames.length; i < j; i++) {
iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
}
}
if ($.browser.safari || $.browser.opera) {
iFrames.load(function () {
setTimeout(iResize, 0);
});
for (var i = 0, j = iFrames.length; i < j; i++) {
var iSource = iFrames[i].src;
iFrames[i].src = '';
iFrames[i].src = iSource;
}
} else {
iFrames.load(function () {
this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
});
}
});
In chrome, it has trouble here:
if ($.browser.safari || $.browser.opera) {
Is there any reason why I get this error? I am using the latest JQuery?
Thanks
Upvotes: 7
Views: 24276
Reputation: 41
I noticed this issue today with a client who upgraded without telling me.
The quick fix I issued (without using Modernizr which is probably a better way)
On the scrollTo.js file go to line 85 and make it this:
var is_safari = navigator.userAgent.indexOf("Safari") > -1;
return is_safari || doc.compatMode == 'BackCompat' ?
Upvotes: 2
Reputation: 13429
You could try checking the userAgent string:
Chrome has both 'Chrome' and 'Safari' inside userAgent string. Safari has only 'Safari'.
Upvotes: 0
Reputation: 849
jquery recommends against $.browser
... use $.support
instead..
if $.browser.safari
(or opera or whatever your trying to access) doesn't exist it throws an error. check if its undefined
Upvotes: 3
Reputation: 2099
You are probably using jQuery 1.9 or above, in which case $.browser
was officially removed after being deprecated since 1.3.
You can use jQuery migrate which will patch it, but it's better to move to a feature specific approach instead of browser specific approach. Modernizr is great for this.
Upvotes: 14