There are a lot of examples and tutorials about how to create grayscale images using CSS , CSS3 and JS, but while developing a project for one of my clients, I found out that there is no solution that would be cross-browser compatible and would support the latest Internet Explorer 10 and 11 versions. This is the reason I came up with a solution of my own and decided to share it with you.
Grayscale filter has been natively supported by Internet Explorer since version 6, but recently Microsoft decided to remove this native CSS filter and since version 10, IE does not display grayscale images using the old technique.
This is the reason why we now have to turn to grayscale JS solution. Besides this, Microsoft has released the new IE11, which is trying to hide as a different browser. Now Internet Explorer 11 has changed its user-agent and pretends to be a Gecko or WebKit browser. This is a pretty nifty move by Microsoft in order to render new IE11 on most browsers as a Gecko browser and not like the previous versions with MSIE user-agent (we all know that there are a lot of websites that check for MSIE user-agent and bring up non-standard markup). So I had to overcome this new problem as well – checking the user-agent and firing only the SVG (Scalable Vector Graphics) grayscale JS solution that is intended for IE10+ (IE6-9 support CSS grayscale).
Grayscale on Opera and Safari
Opera and Safari browsers do not support CSS grayscale filters so these browsers must be treated separately just like IE10+. Only these browsers can be fixed using JS solution which has been kindly provided by James Padolsey
That’s all about my cross-browser grayscale image solution setup. You can check out the demo or download the source. For those of you who want to get into more details, I have explained the magic behind the functions.js file, so that you could tweak the code as you need.
This function getBrowser() checks the browser user agent and after that adds corresponding class to the <body> tag – this way we can target browser with CSS or fire JS functions only on those browsers that we want (Except IE11 because of the new user-agent)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Detection function to tell what kind of browser is used
After we have created a way to tell what kind of browser is used by the user, we can start to target Grayscale image solutions with JS to the browsers that need it. I will start with Opera and Safari
If you have any further questions, suggestions about cross-browser grayscale image example using CSS3 + JS, feel free to write them below or contact me personally.
Link tải phần mềm link Google Drive (tải nhanh): https://drive.google.com/drive/folders/1A-JAxDTXcEcZ-8kWzS9lpZ2BN086Gf5L?usp=sharing Link xem hướng dẫn lấy mã giải nén phần mềm: trên: https://docs.google.com/document/d/1P4Pp2joSl6qAtnjNieoDcU0j7Z1yqUE4/edit?usp=sharing&ouid=112212768248379981623&rtpof=true&sd=true Hôm nay mình sẽ hướng dẫn các bạn khôi phục phân vùng ổ cứng do ghost nhầm, chọn sai lệnh trong recovery bản quyền hệ điều hành trên laptop, xóa nhầm khi thao tác trên các phần mềm phân chia ổ cứng, chạy sai dòng lệnh diskpart. Với tỷ lệ thành công 99% , 1% không thành công là do ổ cứng bị lỗi vật lý (bad sector đoạn chứa Partition Table), do đã dùng các công cụ khác để khôi phục partition nhưng không thành công và đã chia lại ổ cứng. Chỉ với 1 chút sai lầm mà bạn phải trả giá là ổ cứng với một đống dữ liệu quý giá đã “bốc hơi” và chỉ còn thấy 1 ổ đĩa duy nhất. Trong trường hợp này bạn phải bình tĩnh và cẩn thận làm theo từng bước hướng dẫn để khôi
Cách sử dụng 2 phương thức [httppost] và [httpget] trong MVC Giống nhau: Được sử dụng trên các function của controller. Attribute [httpget]: Các function mà trả về dữ liệu và được gọi như page load. Atribute [httppost]: Các function mà dữ liệu trả về sau khi form hoặc ajax gọi phương thức Post. Nếu không dùng cách này, các bạn có thể dùng phướng thức IsPost để xác định khi nào thì phường thức Post được gọi. -----------------------Tài liệu khác----------------------------------------- Sự khác biệt chính giữa GET và POST request là với HTTP GET, tất cả các tham số hay dữ liệu được chuyển đến server được chứa trong chính địa chỉ URL. Điều này có nghĩa là ta có thể gọi trực tiếp các thủ tục của server từ xa thông qua URL và các tham số của nó. Tuy nhiên, để chuyển các tham số, ta bị giới hạn bằng định dạng văn bản đơn giản với độ dài các tham số bị giới hạn bởi kích thước lớn nhất của chiều dài dòng request của máy chủ Web. Ví dụ, trên server Web Tomcat, kích thước tối đa mặc
Hi, Xin chào, I want to format currency vnd(vietnamese) in MVC and it is working for me. Step 1: In model public class MyCurrency { [Display(Name = " Giá ")] public decimal? Price { get; set; } } Step 2: In View @model Demo.Web.Models.CurrencyModel @{ // define format VND var format = System.Globalization.CultureInfo.GetCultureInfo("vi-VN"); var currency = 250000 //example } <div> @String.Format( format , "{0:c0}", currency ); //hoặc nếu các bạn lấy dữ liệu từ model thì thay value bằng biến model, //ví dụ mình thay value bằng @item.Price // @String.Format( format , "{0:c0}", @item.Price ); </div> Và đây là kết quả của tôi: Trong admin tôi nhập: 1050000 Và hiển thị kết quả: Mình làm demo đơn giản để các bạn có thêm nguồn tài liệu tham khảo. Bạn có thể xem thêm các định dạng khác tại Custom numeric format strings hoặc Standa
Nhận xét
Đăng nhận xét