cross-browser

conditionally load javascript resource

假装没事ソ 提交于 2021-02-08 05:15:19
问题 I'm creating a website which some of it's pages contain at least one media player and because of the page size limitations, I want to load the media player javascript file only in pages that have medias. I store media information in an javascript object in head of the page and other script files are being loaded at the end of body. I found this solution (using $.getScript ) very nice but I want a solution that doesn't rely on any frameworks. I saw an interesting implementation in jQuery

Gradient background with text clip for IE11 and safari

断了今生、忘了曾经 提交于 2021-02-07 20:02:17
问题 The example below: h1 { background-image: linear-gradient(to right, #00b140, #bcda00 17%, #bcda00 60%, #00b140); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } <h1>Text11111</h1> Lacks full cross-browser support. Any suggestions? 回答1: Here is clip for background with gradient /** -webkit-background-clip: text Polyfill # What? # A polyfill which replaces the specified element with a SVG in browser where "-webkit-background-clip: text" is not

How to distinguish between refresh (by F5/refresh button) and close browser?

六月ゝ 毕业季﹏ 提交于 2021-02-07 19:44:24
问题 I have requirement to handle events on browser like back, refresh and close on cross browser. The problem is my customer want a different logic for each of those events. For back button, this solution is quite fine: https://stackoverflow.com/a/36786695/3462243 but Now it's hard to distinguish between refresh and close, all solutions i found is about using of "beforeunload" event: How to know whether refresh button or browser back button is clicked in firefox Handle refresh page event with

Detect presence of other tabs / windows of same domain

孤者浪人 提交于 2021-02-07 19:42:06
问题 If I have two (or more) tabs open at the same domain, is there a simple way to sense the presence of the other one, (so as to control what computations I do)? I understand there is a window.open() function, but I am not opening one window from another. Instead imagine a user goes with two tabs to mydomain.com. I have started writing some code doing using HTML5 local storage, where I periodically leave messages and check messages, but this seems a bit convoluted. 回答1: Setting a counter in

How can I revoke an object URL only after it's downloaded?

寵の児 提交于 2021-02-07 14:21:47
问题 I'm saving a file in JavaScript using the following code: var a = document.createElement('a'); a.href = URL.createObjectURL(new Blob(['SOME DATA'])); a.download = 'some.dat'; a.click(); I want to revoke the URL (using URL.revokeObjectURL) once the file is downloaded. When is it safe to do so? Can I revoke it immediately after calling a.click() (which seems to work, but I'm not sure it's safe)? In a 's click event listener? Is there a way to make a click event listener run after the default

HTML/CSS: scroll bar appears below HTML elements

隐身守侯 提交于 2021-02-07 13:03:00
问题 In Chrome and Safari, the vertical scroll bar appears below HTML content on the page, like so: I fiddled with ::-webkit-scrollbar , but the closest i could get was change the scroll bar width to 0px . The div of that section is: .displayContent { min-width:620px; width:100%; height:auto; overflow:hidden; } This occurs in Safari (but not mobile Safari on iOS) and Chrome. Firefox is fine. I also tried fiddling with overflow as well, but could not get the results i wants. Suggestions? 回答1: Try

How can I reliably detect the browser without using window.navigator?

走远了吗. 提交于 2021-02-06 15:26:22
问题 I know there are a thousand questions on Stack Overflow about detecting the browser with JavaScript. My question is how can you detect the browser without window.navigator (which includes navigator.userAgent )? First, to clarify, I don't need to know the rendering engine, this isn't for adaptive layout, and don't panic: I'm already doing feature detection. If why I'm asking about detecting the browser is important, please comment and I'll be happy to splice in the explanation, but it will

How can I reliably detect the browser without using window.navigator?

半城伤御伤魂 提交于 2021-02-06 15:23:05
问题 I know there are a thousand questions on Stack Overflow about detecting the browser with JavaScript. My question is how can you detect the browser without window.navigator (which includes navigator.userAgent )? First, to clarify, I don't need to know the rendering engine, this isn't for adaptive layout, and don't panic: I'm already doing feature detection. If why I'm asking about detecting the browser is important, please comment and I'll be happy to splice in the explanation, but it will

Which browsers support stale-if-error and stale-while-revalidate?

青春壹個敷衍的年華 提交于 2021-02-05 12:13:59
问题 RFC 5861 proposes the Cache-Control extensions stale-while-revalidate: When present in an HTTP response, the stale-while-revalidate Cache- Control extension indicates that caches MAY serve the response in which it appears after it becomes stale, up to the indicated number of seconds. and stale-if-error: The stale-if-error Cache-Control extension indicates that when an error is encountered, a cached stale response MAY be used to satisfy the request, regardless of other freshness information.

Which browsers support stale-if-error and stale-while-revalidate?

≡放荡痞女 提交于 2021-02-05 12:11:32
问题 RFC 5861 proposes the Cache-Control extensions stale-while-revalidate: When present in an HTTP response, the stale-while-revalidate Cache- Control extension indicates that caches MAY serve the response in which it appears after it becomes stale, up to the indicated number of seconds. and stale-if-error: The stale-if-error Cache-Control extension indicates that when an error is encountered, a cached stale response MAY be used to satisfy the request, regardless of other freshness information.