cross-browser

CSS transition does not work on top property in FF

孤街浪徒 提交于 2019-12-29 04:44:45
问题 I have following HTML: <ul> <li> <a href="#"> <h2>title</h2> </a> </li> <li> <a href="#"> <h2>title</h2> </a> </li> <li> <a href="#"> <h2>title</h2> </a> </li> </ul> CSS ul { list-style: none; text-align: center; } ul li { position: relative; float: right; margin-right: 20px; width: 30%; } ul li { transition: all 0.3s; } ul li:hover { top: -10px; } ul li> a{ color: red; } The question is the transition does not work with moz, it works on webkit. How do I implement this in a cross browser way?

How to listen for Ctrl-P key press in JavaScript?

会有一股神秘感。 提交于 2019-12-29 04:30:34
问题 I want to disable print for some webpages. How to wireup cross browser hotkeys (Cntrl + P) to a javascript that will be fired whenever hotkeys are pressed? 回答1: You can override by capturing the event. jQuery(document).bind("keyup keydown", function(e){ if(e.ctrlKey && e.keyCode == 80){ return false; } }); 回答2: Also a great library is Mousetrap 回答3: Try Keyboard Shortcuts Library. Instead of just copy pasting it let's havea look at the source and understand how it works. You can see the

Modify prototypes of every possible DOM element

北慕城南 提交于 2019-12-29 01:43:22
问题 Updated title to better reflect what I'm trying to do. In short, there are different constructors for different dom elements, and they don't seem to all share a common prototype. I'm looking for a way to add a function property to every DOM element by modifying these prototypes, but I'm not sure how to find them. For example, I could do something like this: function enhanceDom (tagNames, methods) { var i=-1, tagName; while (tagName=tagNames[++i]) { var tag=document.createElement(tagName); if

HTML5 input type date, color, range support in Firefox and Internet Explorer

旧城冷巷雨未停 提交于 2019-12-28 11:59:07
问题 I've build all my website using many forms with HTML5 (using the input types date , color and range .) Everything works fine in Google Chrome. But when I turn on Internet Explorer and Firefox, all input fields become like input type text . Is there a way or a script I can download to make forcing the displaying of this input correctly? 回答1: Since HTML5 hasn't been completely standardized yet, not all browsers do support these input types. The intended behaviour is to fall back to <input type=

Reliable Way to Detect Desktop vs. Mobile Browser [duplicate]

天大地大妈咪最大 提交于 2019-12-28 11:46:46
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: What is the Best way to do Browser Detection in Javascript? I'd like to essentially do the following (in JavaScript or PHP): if (desktop browser) { do x; } else { // mobile browser do not do x; } It is known that using a browser detection method is not recommended. A better solution is using a capability testing. My question is, with mobile browsers become smarter and as powerful as the desktop version, what

Are CSS selectors case-sensitive?

点点圈 提交于 2019-12-28 02:51:05
问题 I was recently updating a CMS site and a tab-navigation plugin had inserted the following markup: <li id="News_tab">... I've always written my CSS selectors in lowercase so when I tried to style this with #news_tab , it wouldn't apply, but #News_tab worked. After all these years I'm surprised that I haven't run into this before, so I've always been under the impression that CSS was case-insensitive. Has CSS always been case-sensitive and I just haven't noticed thanks to my consistent code

How to detect supported video formats for the HTML5 video tag?

痞子三分冷 提交于 2019-12-27 20:09:35
问题 I am making an application in HTML5 using the video tag, in the application the user chooses a video file and I play that file. This all happens locally because I only link to that file in the user's machine. I want to allow only formats the browser can play to be played in my application, and to show an error for unsupported formats. The problem is that different browsers can play different formats. I know I can check for the browser and match it with the formats I know it can play, but what

Crossbrowser onbeforeunload?

人走茶凉 提交于 2019-12-27 09:51:09
问题 Does window.onbeforeunload() fire in all browsers? I need a onbeforeunload functionality which is supported at least by IE6 and FF3.6. For IE, onbeforeunload() seems only to be supported by IE9 回答1: I found a workaround for Firefox with setTimeout function because it does not have the same behaviour as other web browsers. window.onbeforeunload = function (e) { var message = "Are you sure ?"; var firefox = /Firefox[\/\s](\d+)/.test(navigator.userAgent); if (firefox) { //Add custom dialog /

Crossbrowser onbeforeunload?

怎甘沉沦 提交于 2019-12-27 09:49:47
问题 Does window.onbeforeunload() fire in all browsers? I need a onbeforeunload functionality which is supported at least by IE6 and FF3.6. For IE, onbeforeunload() seems only to be supported by IE9 回答1: I found a workaround for Firefox with setTimeout function because it does not have the same behaviour as other web browsers. window.onbeforeunload = function (e) { var message = "Are you sure ?"; var firefox = /Firefox[\/\s](\d+)/.test(navigator.userAgent); if (firefox) { //Add custom dialog /

Crossbrowser onbeforeunload?

对着背影说爱祢 提交于 2019-12-27 09:49:31
问题 Does window.onbeforeunload() fire in all browsers? I need a onbeforeunload functionality which is supported at least by IE6 and FF3.6. For IE, onbeforeunload() seems only to be supported by IE9 回答1: I found a workaround for Firefox with setTimeout function because it does not have the same behaviour as other web browsers. window.onbeforeunload = function (e) { var message = "Are you sure ?"; var firefox = /Firefox[\/\s](\d+)/.test(navigator.userAgent); if (firefox) { //Add custom dialog /