Tag: 跨浏览器

当方向是rtl时jQuery.scrollLeft() – 不同浏览器中的不同值

当body方向为rtl时,div的scrollLeft属性似乎在不同的浏览器中返回不同的值。 这里可以看到一个例子 – http://jsfiddle.net/auVLZ/2/ body { direction: rtl; } div.Container { border: 5px solid #F00; width: 500px; height: 400px; overflow: auto; } div.Content { background-color: #00F; width: 900px; height: 380px; }​ ​ $(document).ready(function() { $(“#showScrollLeft”).click(function(e) { alert($(“div.Container”).scrollLeft()); }); });​ Chrome – 初始值为400,向左移动滚动条时为0。 IE8 – 0和400。 Firefox – 0和-400。 造成这种差异的原因是什么?如何处理? 编辑 :请注意,这也发生在“常规”scrollLeft上 – document.getElementById(“divContainer”).scrollLeft返回相同的结果。

onbeforeunload对话框取消与window.location.href IE8错误

对于这个不起眼的标题感到抱歉,希望我能解释一下: 我有一个标准,“你确定要离开”对话框会在用户试图离开页面时弹出: window.onbeforeunload = function() { return ‘You have unsaved changes’; } 当这与window.location.href 并且用户单击取消时 ,Internet Explorer 8或更早版本中将引发“未指定的错误”。 其他现代浏览器似乎也没有发生同样的情况。 $(‘input’).click(function() { window.location.href = ‘http://www.google.com’; // error is thrown here }); 有什么办法可以继续使用window.location.href并在IE8中解决这个bug吗?

如何使用jQuery AJAX加载跨域html页面?

如何使用jQuery AJAX加载跨域HTML页面? 假设我想使用jQuery AJAX在我的域外获取一个页面: $.get(‘http://www.domain.com/mypage.html’, function(data) { alert(data); }); 我可能会收到此错误消息: XMLHttpRequest无法加载http://www.domain.com/path/filename 。 Access-Control-Allow-Origin不允许使用null。 由于Same-origin策略,我们无法使用AJAX加载跨域页面。 我可以尝试使用’jsonp’来绕过这个限制: $.ajax({ type: “GET”, url: url, dataType: “jsonp”, success: function(data){ console.log(data); } }); 但是如果这个网站不支持’jsonp’怎么办? 这可能是个问题。 如果我只想阅读外部页面并解析其HTML,该怎么办?

jQuery animate scrollTop在IE 7中不起作用

以下适用于Chrome / FF等… $(‘body’).animate({scrollTop : 0}, 0); 但是,在IE 7中,它没有做任何事情。 还有其他选择吗?

如何在JavaScript中听Ctrl-P键按?

我想禁用某些网页的打印。 如何将浏览器热键(Cntrl + P)连接到按下热键时将触发的javascript?

preventDefault不适用于Firefox

我试图阻止A HREF实际打开链接,但是要执行脚本。 我让脚本部分工作,但似乎Firefox会忽略这个: $(“#permalink a”).click(function(id){ $(“#newPost”).fadeToggle; event.preventDefault(); var id = this.getAttribute(‘href’); $(“#newPostContent”).load(id); $(“#newPost”).show(“fast”); }); 任何人都可以建议使用跨浏览器脚本来防止默认设置吗?

检测所有浏览器中是否打开了console / devtools

我正在尝试创建一个在打开或关闭任何浏览器控制台时运行的脚本。 有没有办法检测所有浏览器(Firefox / IE / Chrome / Safari / Opera)中的浏览器控制台是否通过JavaScript,jQuery或任何其他客户端脚本打开?

如何使用javascript检测IE10?

正如许多已经在其他问题(也在jQuery文档中)中发布的那样,旧的jQuery.browser.version已被弃用,仅适用于jquery1.3。 您是否知道另一种检测它的简单方法,我可以在之前的代码中包含: function handleInfoDivPopupVisibility(dynamicEleId, staticEleId){ var parentContainer = $(‘headerSummaryContainer’); var dynamicEle = $(dynamicEleId); var staticEle = $(staticEleId); if(isIE() && parentContainer){ if (jQuery.browser.version != 10) { // I need to find a way to detect if it’s IE10 here. parentContainer.style.overflow = ‘visible’; } } dynamicEle ? dynamicEle.style.display = ” : ”; if(dynamicEle && staticEle) gui_positionBelow(dynamicEle, staticEle); […]

jQuery javascript自定义排序程序在Firefox中运行,但IE似乎没有得到它…(复制粘贴示例代码)

我根据应用程序中的实际问题构建了此示例代码。 我有一个自定义排序过程来排序jQuery数组。 容器包含具有特殊属性的项列表。 用于分类: 加载临时数组中的所有项目 清除容器 将临时数组排序为新数组 将已排序的项目附加到容器 不知何故,Firefox知道如何排序,但IE不知道。 有人能告诉我什么不能正常工作吗? (你可以将下面的html复制粘贴到一个空的.html文件中,它应该立即工作) jQuery.fn.sort = function() { return this.pushStack( [].sort.apply( this, arguments ), []); } function DoTheSort() { //Fetch elements in jQueryElement var sortableArray = $(‘#sortables’).find(‘div.sortable’); //Clear the sortables container $(‘#sortables’).empty(); //Sort the array var sortedArray = $(sortableArray).sort(sortProcedure); //Append sorted items jQuery.each(sortedArray, function() { alert($(this).attr(“sortvalue”)); $(‘#sortables’).append(this); }); […]

如何使用jQuery.support检测IE7和IE8

如何使用jQuery.support属性检测IE 7和IE 8? 是否可以使用jQuery.support检测浏览器版本或只是那些等等等等?