摘要:只在中存放不敏感數(shù)據(jù),即使被盜也不會有重大損失。每個最多只能有條,每個長度不能超過,否則會被截掉。除此之外,擁有等方法,不像需要前端開發(fā)者自己封裝,。控制表單控件的禁用狀態(tài)。規(guī)定了三種文檔類型以及。
說說你對閉包的理解 Talk about your understanding of closures
使用閉包主要是為了設(shè)計私有的方法和變量。閉包的優(yōu)點是可以避免全局變量的污染,缺點是閉包會常駐內(nèi)存,會增大內(nèi)存使用量,使用不當(dāng)很容易造成內(nèi)存泄露。
Using closures designed primarily to private methods and variables. Closure advantage of global variables are avoided contamination, the disadvantage is the closure will be permanent memory, the memory usage increases, improper use is likely to cause a memory leak.
閉包有三個特性:
Closures have three characteristics:
1.函數(shù)嵌套函數(shù)
2.函數(shù)內(nèi)部可以引用外部的參數(shù)和變量
3.參數(shù)和變量不會被垃圾回收機制回收
Function
The internal function nested function can refer to external parameters and variables
The parameters and variables will not be garbage collection mechanism Recycling
請你談?wù)凜ookie的弊端
You talk about the shortcomings of Cookiecookie雖然在持久保存客戶端數(shù)據(jù)提供了方便,分擔(dān)了服務(wù)器存儲的負(fù)擔(dān),但還是有很多局限性的。
第一:每個特定的域名下最多生成20個cookie
1.IE6或更低版本最多20個cookie 2.IE7和之后的版本最后可以有50個cookie。 3.Firefox最多50個cookie 4.chrome和Safari沒有做硬性限制 1.IE6 or earlier up to 20 cookie 2.IE7 later version and last may have 50 cookie. 3.Firefox up to 50 cookie 4.chrome and Safari does not do hard limit. IE and Opera will clean up the least recently used cookie , Firefox will randomly to clean cookie .
IE和Opera 會清理近期最少使用的cookie,Firefox會隨機清理cookie。
cookie的最大大約為4096字節(jié),為了兼容性,一般不能超過4095字節(jié)。
IE 提供了一種存儲可以持久化用戶數(shù)據(jù),叫做userdata,從IE5.0就開始支持。每個數(shù)據(jù)最多128K,每個域名下最多1M。這個持久化數(shù)據(jù)放在緩存中,如果緩存沒有清理,那么會一直存在。
IE can provide a way to store persistent user data, called UserData , from IE5.0 has supported. Each data up to 128K, under each domain up to 1M. The persistent data in the cache, if not cleaned the cache, it will always exist.
優(yōu)點:極高的擴展性和可用性 Advantages: high scalability and availability1.通過良好的編程,控制保存在cookie中的session對象的大小。 2.通過加密和安全傳輸技術(shù)(SSL),減少cookie被破解的可能性。 3.只在cookie中存放不敏感數(shù)據(jù),即使被盜也不會有重大損失。 4.控制cookie的生命期,使之不會永遠(yuǎn)有效。偷盜者很可能拿到一個過期的cookie。
Good programming, control the size of the session cookie stored in the object.
encryption and secure transmission technology (SSL), to reduce the possibility of cookie to crack.
Only non-sensitive data is stored in a cookie, even if stolen will not have significant losses.
Control cookie lifetime, so it will not always be effective. Theft are likely to get an expired cookie.
缺點: Disadvantages:1.`Cookie`數(shù)量和長度的限制。每個domain最多只能有20條cookie,每個cookie長度不能超過4KB,否則會被截掉。 2.安全性問題。如果cookie被人攔截了,那人就可以取得所有的session信息。即使加密也與事無補,因為攔截者并不需要知道cookie的意義,他只要原樣轉(zhuǎn)發(fā)cookie就可以達(dá)到目的了。 3.有些狀態(tài)不可能保存在客戶端。例如,為了防止重復(fù)提交表單,我們需要在服務(wù)器端保存一個計數(shù)器。如果我們把這個計數(shù)器保存在客戶端,那么它起不到任何作用。 1.`Cookie` limit the number and length. Each domain can have a maximum of 20 cookie, each cookie length can not exceed 4KB, otherwise it will be truncated.
The security issues. If the cookie is intercepted, that person can get all the session information. Even if encryption is also unhelpful, because Interceptor does not need to know the meaning of the cookie, cookie forwarding as long as he can achieve their goals.
Some state can not be stored in the client. For example, in order to prevent duplicate submission form, we need to save a counter on the server side. If we put this counter is stored in the client, then it will not achieve any effect.
Browser local storage
在較高版本的瀏覽器中,js提供了sessionStorage和globalStorage。在HTML5中提供了localStorage來取代globalStorage。
In later versions of the browser, JS provides sessionStorage and globalStorage . In HTML5 provides in localStorage to replace globalStorage.
html5中的Web Storage包括了兩種存儲方式:sessionStorage和localStorage。
html5 The Web Storage includes two storage methods: sessionStorage and localStorage .
sessionStorage用于本地存儲一個會話(session)中的數(shù)據(jù),這些數(shù)據(jù)只有在同一個會話中的頁面才能訪問并且當(dāng)會話結(jié)束后數(shù)據(jù)也隨之銷毀。因此sessionStorage不是一種持久化的本地存儲,僅僅是會話級別的存儲。
sessionStorage data stored locally for a session (session) in which the data only in the same session of the page to access data, and when the end of the session also will be destroyed. So sessionStorage not a persistent local storage, just session-level storage.
而localStorage用于持久化的本地存儲,除非主動刪除數(shù)據(jù),否則數(shù)據(jù)是永遠(yuǎn)不會過期的。
And localStorage for persistent local storage, unless the initiative to remove the data, or the data is never out of date.
web storage和cookie的區(qū)別 the difference between web storage and a cookieWeb Storage的概念和cookie相似,區(qū)別是它是為了更大容量存儲設(shè)計的。Cookie的大小是受限的,并且每次你請求一個新的頁面的時候Cookie都會被發(fā)送過去,這樣無形中浪費了帶寬,另外cookie還需要指定作用域,不可以跨域調(diào)用。
Web Storage concept and cookie similar, except that it is designed for higher-capacity storage. Cookie size is limited, and every time you request a new page when the Cookie will be sent in the past, so that virtually waste bandwidth, another cookie also need to specify the scope, not cross-domain calls.
除此之外,Web Storage擁有setItem,getItem,removeItem,clear等方法,不像cookie需要前端開發(fā)者自己封裝setCookie,getCookie。
In addition, Web Storage has setItem, getItem, removeItem, clear methods, unlike the cookie front-end developers need their own package setCookie, getCookie.
但是cookie也是不可以或缺的:cookie的作用是與服務(wù)器進行交互,作為HTTP規(guī)范的一部分而存在 ,而Web Storage僅僅是為了在本地“存儲”數(shù)據(jù)而生
But the cookie is not indispensable: cookie "s role is to interact with the server as HTTP part of the specification exists, and Web Storage simply to the local "store" raw data
瀏覽器的支持除了IE7及以下不支持外,其他標(biāo)準(zhǔn)瀏覽器都完全支持(ie及FF需在web服務(wù)器里運行),值得一提的是IE總是辦好事,例如IE7、IE6中的userData其實就是javascript本地存儲的解決方案。通過簡單的代碼封裝可以統(tǒng)一到所有的瀏覽器都支持web storage。
Browser support in addition to IE7 and below are not supported, other standard browsers fully support (ie and FF need to run a web server in), it is worth mentioning that IE always good things, such as IE7, IE6 in the userData fact is javascript local storage solutions. By simple code package can be unified to all the browsers support Web storage.
localStorage和sessionStorage都具有相同的操作方法,例如setItem、getItem和removeItem等
localStorage and sessionStorage have the same method of operation, for example setItem, getItem and removeItem etc.
cookie 和session 的區(qū)別: cookie and session distinction:1、cookie數(shù)據(jù)存放在客戶的瀏覽器上,session數(shù)據(jù)放在服務(wù)器上。 2、cookie不是很安全,別人可以分析存放在本地的COOKIE并進行COOKIE欺騙 考慮到安全應(yīng)當(dāng)使用session。 3、session會在一定時間內(nèi)保存在服務(wù)器上。當(dāng)訪問增多,會比較占用你服務(wù)器的性能 考慮到減輕服務(wù)器性能方面,應(yīng)當(dāng)使用COOKIE。 4、單個cookie保存的數(shù)據(jù)不能超過4K,很多瀏覽器都限制一個站點最多保存20個cookie。 5、所以個人建議: 將登陸信息等重要信息存放為SESSION 其他信息如果需要保留,可以放在COOKIE中 1, cookie data is stored on the customer"s browser, session data on the server. 2, cookie is not very safe, others can be analyzed at a local store and COOKIE COOKIE cheat should be used taking into account the security session. 3, session will be within a certain time saved on the server. When accessing the increase, it would be more occupy the performance of your server consider to reduce server performance, you should use COOKIE. 4, the data stored in a single cookie can not exceed 4K, many browsers are limited to a maximum of one site to save 20 cookie. 5, so personal recommendations: the login information and other important information is stored as SESSION additional information, if necessary, it can be placed in COOKIE
CSS 相關(guān)問題
CSS-related issues display:none和visibility:hidden的區(qū)別? display: none and visibility: hidden difference?display:none 隱藏對應(yīng)的元素,在文檔布局中不再給它分配空間,它各邊的元素會合攏, 就當(dāng)他從來不存在。 visibility:hidden 隱藏對應(yīng)的元素,但是在文檔布局中仍保留原來的空間。 display: none to hide the corresponding elements in the document layout is no longer space allocated to it, it is the element of each side will be closed, on when he never existed. visibility: hidden hides the corresponding elements, but still retain the original layout of the space in the document. The difference in the link andimport CSS is?CSS中 link 和@import 的區(qū)別是? The difference in the link andimport CSS is?
(1) link屬于HTML標(biāo)簽,而@import是CSS提供的; (2) 頁面被加載的時,link會同時被加載,而@import引用的CSS會等到頁面被加載完再加載; (3) import只在IE5以上才能識別,而link是HTML標(biāo)簽,無兼容問題; (4) link方式的樣式的權(quán)重 高于@import的權(quán)重. (1) link belong to HTML tags, and CSSimport is provided; (2) the page is loaded, link will also be loaded, but referencesimport CSS will wait until the page is finished loading reloading; (3) Import only to recognize in IE5 or more, while link is HTML tag, no compatibility issues; style right (4) linkimport way of weight above the weight of heavy. Similarities and Differences between absolute and float attributes: positionposition:absolute和float屬性的異同 Similarities and Differences between absolute and float attributes: position
A:共同點: 對內(nèi)聯(lián)元素設(shè)置`float`和`absolute`屬性,可以讓元素脫離文檔流,并且可以設(shè)置其寬高。 B:不同點: float仍會占據(jù)位置,position會覆蓋文檔流中的其他元素。 A: common: inline element set `float` and` absolute` property allows elements from the document flow, and can set its width and height. B: Different point: float will still occupy the position, position overrides other elements in the document flow.介紹一下box-sizing屬性? Introduce the box-sizing property?
box-sizing屬性主要用來控制元素的盒模型的解析模式。默認(rèn)值是content-box。
box-sizing property is primarily used to control element analytical model box model. The default value is content-Box.
content-box:讓元素維持W3C的標(biāo)準(zhǔn)盒模型。元素的寬度/高度由border + padding + content的寬度/高度決定,設(shè)置width/height屬性指的是content部分的寬/高
content-Box : Let element to maintain the standard W3C box model. Width / height of the element / height is determined by the border + padding + content width, set width / height attribute refers to the content portion of the width / height
border-box:讓元素維持IE傳統(tǒng)盒模型(IE6以下版本和IE6~7的怪異模式)。設(shè)置width/height屬性指的是border + padding + content
border-Box : Let element to maintain the traditional box model IE (IE6 and IE6 ~ 7 the following versions of quirks mode). Set width / height attribute refers to the border + padding + content
標(biāo)準(zhǔn)瀏覽器下,按照W3C規(guī)范對盒模型解析,一旦修改了元素的邊框或內(nèi)距,就會影響元素的盒子尺寸,就不得不重新計算元素的盒子尺寸,從而影響整個頁面的布局。
Under standard browser, according to W3C box model specification analysis, once the border or modify the elements within distance, it will affect the size of the box element, you have to recalculate the box the size of the elements, thus affecting the layout of the entire page.
CSS 選擇符有哪些?哪些屬性可以繼承?優(yōu)先級算法如何計算? CSS3新增偽類有那些? CSS selectors are there? Which attributes can be inherited? Priority algorithm calculated? Added CSS3 pseudo-classes are those?1.id選擇器( # myid) 2.類選擇器(.myclassname) 3.標(biāo)簽選擇器(div, h1, p) 4.相鄰選擇器(h1 + p) 5.子選擇器(ul > li) 6.后代選擇器(li a) 7.通配符選擇器( * ) 8.屬性選擇器(a[rel = "external"]) 9.偽類選擇器(a: hover, li:nth-child) 1.id selector (# myid)
Class selector (.myclassname)
Tag selectors (div, h1, P)
adjacent selector (h1 + P)
child selector (ul> li )
descendant selectors (li a)
wildcard selector (*)
attribute selector (a [rel = "external"])
pseudo-class selectors (a: hover, li: nth-child)
可繼承的樣式: font-size font-family color, text-indent;
不可繼承的樣式:border padding margin width height ;
優(yōu)先級就近原則,同權(quán)重情況下樣式定義最近者為準(zhǔn);
載入樣式以最后載入的定位為準(zhǔn);
Inheritable style: font-size font-family color, text-indent;
Non Inherited Styles: border padding margin width height;
Priority under the principle of proximity, with weights whichever the case recently defined style;
Loading last loaded positioning styles to prevail;
優(yōu)先級為:
Priority:
!important > id > class > tag important 比 內(nèi)聯(lián)優(yōu)先級高,但內(nèi)聯(lián)比 id 要高
position的值, relative和absolute分別是相對于誰進行定位的? position values, relative and absolute are positioned with respect to whom?CSS3新增偽類舉例:
p:first-of-type 選擇屬于其父元素的首個元素的每個
元素。 p:last-of-type 選擇屬于其父元素的最后
元素的每個
元素。 p:only-of-type 選擇屬于其父元素唯一的
元素的每個
元素。 p:only-child 選擇屬于其父元素的唯一子元素的每個
元素。 p:nth-child(2) 選擇屬于其父元素的第二個子元素的每個
元素。 :enabled :disabled 控制表單控件的禁用狀態(tài)。 :checked 單選框或復(fù)選框被選中。
absolute 生成絕對定位的元素, 相對于最近一級的 定位不是 static 的父元素來進行定位。 fixed (老IE不支持) 生成絕對定位的元素,相對于瀏覽器窗口進行定位。 relative 生成相對定位的元素,相對于其在普通流中的位置進行定位。 static 默認(rèn)值。沒有定位,元素出現(xiàn)在正常的流中 absolute generate absolute element positioned relative to the recent level is not static positioned parent element to be positioned. fixed (old IE does not support) to generate absolute element positioned relative to the browser window positioning. relative generating element relative positioning, relative to its position in the general stream positioning. static default. No positioning element occurs in the normal streamCSS3有哪些新特性? CSS3 What"s new?
CSS3實現(xiàn)圓角(border-radius),陰影(box-shadow), 對文字加特效(text-shadow、),線性漸變(gradient),旋轉(zhuǎn)(transform) transform:rotate(9deg) scale(0.85,0.90) translate(0px,-30px) skew(-9deg,0deg);//旋轉(zhuǎn),縮放,定位,傾斜 增加了更多的CSS選擇器 多背景 rgba 在CSS3中唯一引入的偽元素是::selection. 媒體查詢,多欄布局 border-image CSS3 rounded corners (border-radius), shadow (box-shadow), add special effects to the text (text-shadow,), a linear gradient (gradient), rotation (transform) transform: Rotate (9deg) Scale (0.85,0.90) translate (0px, -30px) skew (-9deg, 0deg); // rotation, scaling, positioning, tilt adds more CSS selectors more background rgba unique introduced in CSS3 pseudo-elements :: selection. Media queries , multi-column layout border-imageXML和JSON的區(qū)別? XML and JSON difference?
(1).數(shù)據(jù)體積方面。 JSON相對于XML來講,數(shù)據(jù)的體積小,傳遞的速度更快些。 (2).數(shù)據(jù)交互方面。 JSON與JavaScript的交互更加方便,更容易解析處理,更好的數(shù)據(jù)交互。 (3).數(shù)據(jù)描述方面。 JSON對數(shù)據(jù)的描述性比XML較差。 (4).傳輸速度方面。 JSON的速度要遠(yuǎn)遠(yuǎn)快于XML。 (1) The data volume terms. XML JSON relative terms, the volume of data is small, the speed of delivery faster. (2) aspects of data exchange. JSON and JavaScript interaction more convenient and easier to parse processing, better data interaction. (3) The data described aspects. JSON description of data than XML poor. (4) The transmission speed. JSON"s speed is much faster than XML.對BFC規(guī)范的理解? BFC norms of understanding?
BFC,塊級格式化上下文,一個創(chuàng)建了新的BFC的盒子是獨立布局的,盒子里面的子元素的樣式不會影響到外面的元素。在同一個BFC中的兩個毗鄰的塊級盒在垂直方向(和布局方向有關(guān)系)的margin會發(fā)生折疊。 (W3C CSS 2.1 規(guī)范中的一個概念,它決定了元素如何對其內(nèi)容進行布局,以及與其他元素的關(guān)系和相互作用。) BFC, block-level formatting context, a BFC created a new box is an independent layout, style, child elements inside the box will not affect the outside elements. In the same BFC two adjoining block-level box in the vertical direction (the direction of a relationship and layout) of margin will collapse from happening. (A concept W3C CSS 2.1 specification, which determines how the elements in the layout of its contents, and its relationship with other elements and interactions.)解釋下 CSS sprites,以及你要如何在頁面或網(wǎng)站中使用它。 Talk about your understanding of the semantic?
CSS Sprites其實就是把網(wǎng)頁中一些背景圖片整合到一張圖片文件中,再利用CSS的“background-image”,“background- repeat”,“background-position”的組合進行背景定位,background-position可以用數(shù)字能精確的定位出背景圖片的位置。這樣可以減少很多圖片請求的開銷,因為請求耗時比較長;請求雖然可以并發(fā),但是也有限制,一般瀏覽器都是6個。對于未來而言,就不需要這樣做了,因為有了`http2`。 CSS Sprites in fact, the number of pages in the background image into an image file, and then use the CSS "background-image", "background- repeat", "background-position" a combination of background positioning, background-position can be used Digital can accurately locate the position of the background image. This can reduce the cost of many pictures request because the request takes a relatively long; although requests can be complicated, but there are limits, are six general browser. For the future, there is no need to do so, and because of `http2`.html部分 html part 說說你對語義化的理解? Talk about your understanding of the semantic?
1,去掉或者丟失樣式的時候能夠讓頁面呈現(xiàn)出清晰的結(jié)構(gòu) 2,有利于SEO:和搜索引擎建立良好溝通,有助于爬蟲抓取更多的有效信息:爬蟲依賴于標(biāo)簽來確定上下文和各個關(guān)鍵字的權(quán)重; 3,方便其他設(shè)備解析(如屏幕閱讀器、盲人閱讀器、移動設(shè)備)以意義的方式來渲染網(wǎng)頁; 4,便于團隊開發(fā)和維護,語義化更具可讀性,是下一步吧網(wǎng)頁的重要動向,遵循W3C標(biāo)準(zhǔn)的團隊都遵循這個標(biāo)準(zhǔn),可以減少差異化。 1, removed or lost when allowing page style showing clear structure 2, is conducive to SEO: search engines and to establish good communication helps crawlers to crawl more useful information: reptiles rely on labels to determine the context and the individual right keyword weight; 3, easy to resolve other devices (such as a screen reader, blind readers, mobile devices) in meaningful ways to render web pages; 4, easy to team development and maintenance, more readable semantic, is under Important Trends step right of the page, follow the W3C standards team follow this standard, the difference can be reduced.Doctype作用? 嚴(yán)格模式與混雜模式如何區(qū)分?它們有何意義? Doctype role? Strict mode and mixed mode how to distinguish? They mean?
(1)、 聲明位于文檔中的最前面,處于 標(biāo)簽之前。告知瀏覽器以何種模式來渲染文檔。 (2)、嚴(yán)格模式的排版和 JS 運作模式是 以該瀏覽器支持的最高標(biāo)準(zhǔn)運行。 (3)、在混雜模式中,頁面以寬松的向后兼容的方式顯示。模擬老式瀏覽器的行為以防止站點無法工作。 (4)、DOCTYPE不存在或格式不正確會導(dǎo)致文檔以混雜模式呈現(xiàn)。 (1), declaration in the document in the front, in the tag before. Tells the browser to render the document in which mode. (2) strict mode layout and JS mode of operation is based on the highest standards of the browser supports running. (3), in promiscuous mode, page backward compatible with liberal display. Simulate the behavior of older browsers do not work to prevent the site. (4), DOCTYPE does not exist or incorrectly formatted document will lead to promiscuous mode rendering.你知道多少種Doctype文檔類型? Do you know how many document types Doctype?
該標(biāo)簽可聲明三種 DTD 類型,分別表示嚴(yán)格版本、過渡版本以及基于框架的 HTML 文檔。 HTML 4.01 規(guī)定了三種文檔類型:Strict、Transitional 以及 Frameset。 XHTML 1.0 規(guī)定了三種 XML 文檔類型:Strict、Transitional 以及 Frameset。 Standards (標(biāo)準(zhǔn))模式(也就是嚴(yán)格呈現(xiàn)模式)用于呈現(xiàn)遵循最新標(biāo)準(zhǔn)的網(wǎng)頁,而 Quirks (包容)模式(也就是松散呈現(xiàn)模式或者兼容模式)用于呈現(xiàn)為傳統(tǒng)瀏覽器而設(shè)計的網(wǎng)頁。 The label can be declared DTD three types, respectively strict version, interim version and an HTML-based documentation framework. HTML 4.01 specifies three document types: Strict, Transitional, and Frameset. XHTML 1.0 specifies three XML document types: Strict, Transitional, and Frameset. Standards (standard) mode (that is, in strict rendering mode) complies with the latest standards for rendering Web pages, while Quirks
(inclusive) mode (that is, loose rendering mode or compatibility mode) is used to render conventional web browser designed.
HTML與XHTML——二者有什么區(qū)別 HTML and XHTML-- What is the difference區(qū)別: 1.所有的標(biāo)記都必須要有一個相應(yīng)的結(jié)束標(biāo)記 2.所有標(biāo)簽的元素和屬性的名字都必須使用小寫 3.所有的XML標(biāo)記都必須合理嵌套 4.所有的屬性必須用引號""括起來 5.把所有<和&特殊符號用編碼表示 6.給所有屬性賦一個值 7.不要在注釋內(nèi)容中使“--” 8.圖片必須有說明文字 Difference:
All tags must have a corresponding end tag element and attribute names
All tags must be lowercase
All the XML tags must be properly nested
All attributes must be quoted. " "enclosed
Put all the
assign a value to all of the properties in the comment 7. Do not manipulation "-"
The image must have caption
常見兼容性問題? Common compatibility problems?png24位的圖片在iE6瀏覽器上出現(xiàn)背景,解決方案是做成PNG8.也可以引用一段腳本處理.
瀏覽器默認(rèn)的margin和padding不同。解決方案是加一個全局的*{margin:0;padding:0;}來統(tǒng)一。
IE6雙邊距bug:塊屬性標(biāo)簽float后,又有橫行的margin情況下,在ie6顯示margin比設(shè)置的大。
浮動ie產(chǎn)生的雙倍距離(IE6雙邊距問題:在IE6下,如果對元素設(shè)置了浮動,同時又設(shè)置了margin-left或margin-right,margin值會加倍。)
#box{ float:left; width:10px; margin:0 0 0 100px;}
這種情況之下IE會產(chǎn)生20px的距離,解決方案是在float的標(biāo)簽樣式控制中加入 ——_display:inline;將其轉(zhuǎn)化為行內(nèi)屬性。(_這個符號只有ie6會識別)
漸進識別的方式,從總體中逐漸排除局部。
Png24 bit image appears on iE6 browser background, the solution is made ??PNG8. It can refer to a script processing.
The browser"s default margin and padding. The solution is to add a global * {margin: 0; padding: 0;} to unify.
IE6 bilateral Distance bug: After the block attribute labels float, there are rampant margin circumstances, in ie6 show larger margin than the settings.
Double ie generated from the float (IE6 bilateral distance problem: In IE6, if the element is set to float, while setting the margin-left or margin-right, margin value will double.)
#box {float: left; width: 10px; margin: 0 0 0 100px;}
Under such circumstances IE will produce 20px distance, the solution is to add --_ display in the label style float control: inline; be converted to inline property. (_ This symbol identifies only ie6)
gradual recognition of the way from the local population gradually excluded.
首先,巧妙的使用“9”這一標(biāo)記,將IE游覽器從所有情況中分離出來。
接著,再次使用“+”將IE8和IE7、IE6分離開來,這樣IE8已經(jīng)獨立識別。
First, the clever use of " 9" This marks the IE"s browser separated out from all the circumstances.
Then, again using the "+" to IE8 and IE7, IE6 separated, so that IE8 has been independently identified.
css
.bb{ background-color:#f1ee18;/*所有識別*/ .background-color:#00deff9; /*IE6、7、8識別*/ +background-color:#a200ff;/*IE6、7識別*/ _background-color:#1e0bd1;/*IE6識別*/ }
IE下,可以使用獲取常規(guī)屬性的方法來獲取自定義屬性,
也可以使用getAttribute()獲取自定義屬性;
Firefox下,只能使用getAttribute()獲取自定義屬性.
解決方法:統(tǒng)一通過getAttribute()獲取自定義屬性.
IE下,event對象有x,y屬性,但是沒有pageX,pageY屬性;
Firefox下,event對象有pageX,pageY屬性,但是沒有x,y屬性.
解決方法:(條件注釋)缺點是在IE瀏覽器下可能會增加額外的HTTP請求數(shù)。
Chrome 中文界面下默認(rèn)會將小于 12px 的文本強制按照 12px 顯示,
可通過加入 CSS 屬性 -webkit-text-size-adjust: none; 解決.
超鏈接訪問過后hover樣式就不出現(xiàn)了 被點擊訪問過的超鏈接樣式不在具有hover和active了解決方法是改變CSS屬性的排列順序:
L-V-H-A : a:link {} a:visited {} a:hover {} a:active {}
怪異模式問題:漏寫DTD聲明,F(xiàn)irefox仍然會按照標(biāo)準(zhǔn)模式來解析網(wǎng)頁,但在IE中會觸發(fā)怪異模式。為避免怪異模式給我們帶來不必要的麻煩,最好養(yǎng)成書寫DTD聲明的好習(xí)慣。現(xiàn)在可以使用html5推薦的寫法:
上下margin重合問題
ie和ff都存在,相鄰的兩個div的margin-left和margin-right不會重合,但是margin-top和margin-bottom卻會發(fā)生重合。
解決方法,養(yǎng)成良好的代碼編寫習(xí)慣,同時采用margin-top或者同時采用margin-bottom。
ie6對png圖片格式支持不好(引用一段腳本處理)
under IE, you can use the method to get the general properties for custom properties,
can also use getAttribute () Gets the custom attributes;
under Firefox, only Use getAttribute () Gets custom attributes.
Workaround: Uniform for custom properties through getAttribute ().
Under IE, event object has x, y attributes, but no pageX, pageY property;
Firefox, event object has pageX, pageY property, but there is no x, y properties.
Solution :( conditional comments) drawback is that in IE browser may add additional HTTP requests.
Under Chrome Chinese interface will be smaller than default to force the 12px 12px text display,
the addition of CSS properties -webkit-text-size-adjust: none; resolved.
After hover style is not accessible by hyperlink is clicked appears visited The Hyperlink style does not have hover and active the solution is to change the order of CSS properties:
LVHA: a: link {} a: visited {} a: hover {} a: Active {}
weird modalities: Leakage write DTD statement, Firefox will still be in accordance with the standard model to resolve the page, but IE will trigger quirks mode. To avoid quirks mode gives us unnecessary trouble, it is best to develop the good habit of writing DTD declaration. You can now use [html5] (http://www.w3.org/TR/html5/single-page.html) recommended notation:
top and bottom margin overlap problem
and ff are present, adjacent both margin-left and margin-right does not coincide div, but margin-top and margin-bottom but it will coincide occur.
Solution, to develop good coding habits, while using margin-top or while using margin-bottom.
Ie6 png image format support is not good for (quote a script processing)
解釋下浮動和它的工作原理?清除浮動的技巧 Floating and explain how it works? Clear float tips浮動元素脫離文檔流,不占據(jù)空間。浮動元素碰到包含它的邊框或者浮動元素的邊框停留。 Floating elements from the document flow, does not occupy space. Floats across the border to stay its borders contain or floating elements. 1.使用空標(biāo)簽清除浮動。 這種方法是在所有浮動標(biāo)簽后面添加一個空標(biāo)簽 定義css clear:both. 弊端就是增加了無意義標(biāo)簽。 2.使用overflow。 給包含浮動元素的父標(biāo)簽添加css屬性 overflow:auto; zoom:1; zoom:1用于兼容IE6。 3.使用after偽對象清除浮動。 該方法只適用于非IE瀏覽器。具體寫法可參照以下示例。使用中需注意以下幾點。一、該方法中必須為需要清除浮動元素的偽對象中設(shè)置 height:0,否則該元素會比實際高出若干像素;
Clear float with an empty label. This method is to add an empty label definition css clear in all floating behind the label: both the disadvantages is to increase the meaningless labels.
Use the overflow. To a parent tag contains floating elements add css property overflow: auto; zoom: 1; zoom: 1 for compatibility with IE6.
Use after pseudo remove floating objects. This method applies only to non-IE browsers. Specific wording may refer to the following examples. Use should pay attention to the following points. First, the method must be set to clear the height of the floating element"s pseudo-objects: 0, otherwise the element will be much higher than the actual number of pixels;
浮動元素引起的問題和解決辦法? Problems caused by floating elements and solutions?浮動元素引起的問題: Problems caused by the floating elements: (1)父元素的高度無法被撐開,影響與父元素同級的元素 (2)與浮動元素同級的非浮動元素(內(nèi)聯(lián)元素)會跟隨其后 (3)若非第一個元素浮動,則該元素之前的元素也需要浮動,否則會影響頁面顯示的結(jié)構(gòu) (1) height of the parent element can not be softened, peer influence and elements of the parent element (2) and non-floating elements floating element siblings (inline elements) will follow thereafter (3) if not the first element of float, then that element is also required before the float, otherwise it will affect the structure of the page displayed
解決方法:
使用CSS中的clear:both;屬性來清除元素的浮動可解決2、3問題,對于問題1,添加如下樣式,給父元素添加clearfix樣式:
Workaround: use CSS in Clear: Both ; attribute to clear floating elements 2,3 resolve the problem, the problem 1, add the following styles to parent element Add clearfix style:
.clearfix:after{content: ".";display: block;height: 0;clear: both;visibility: hidden;} .clearfix{display: inline-block;} /* for IE/Mac */
清除浮動的幾種方法:
1,額外標(biāo)簽法,(缺點:不過這個辦法會增加額外的標(biāo)簽使HTML結(jié)構(gòu)看起來不夠簡潔。) 2,使用after偽類
Clear float several ways:
1, additional labeling,div> (disadvantage: But this approach would cause additional HTML tag structure looks simple enough) 2, use after pseudo-class #parent:after{ content:"."; height:0; visibility:hidden; display:block; clear:both; } 3,浮動外部元素 4,設(shè)置`overflow`為`hidden`或者auto 3, floating external element 4, is set to `hidden`` overflow` or auto IE 8以下版本的瀏覽器中的盒模型有什么不同 IE 8 the following versions of the browser box model What is the differenceIE8以下瀏覽器的盒模型中定義的元素的寬高不包括內(nèi)邊距和邊框 The following box model IE8 browser"s width and height defined elements does not include padding and borderDOM操作——怎樣添加、移除、移動、復(fù)制、創(chuàng)建和查找節(jié)點。 DOM manipulation - how to add, remove, move, copy, create, and find nodes.(1)創(chuàng)建新節(jié)點 createDocumentFragment() //創(chuàng)建一個DOM片段 createElement() //創(chuàng)建一個具體的元素 createTextNode() //創(chuàng)建一個文本節(jié)點 (2)添加、移除、替換、插入 appendChild() removeChild() replaceChild() insertBefore() //在已有的子節(jié)點前插入一個新的子節(jié)點 (3)查找 getElementsByTagName() //通過標(biāo)簽名稱 getElementsByName() //通過元素的Name屬性的值(IE容錯能力較強,會得到一個數(shù)組,其中包括id等于name值的) getElementById() //通過元素Id,唯一性 (1) Create a new node createDocumentFragment () // Create a DOM fragment createElement () // create a specific element createTextNode () // Create a text node (2) to add, remove, replace, insert appendChild () removeChild ( ) replaceChild () insertBefore () // before the existing child node into a new child node(3) Find
getElementsByTagName () // by tag name getElementsByName () // by the value of the Name property of the element (IE fault tolerance Strong, will be an array, including name id equal value) getElementById () // by elemental Id, uniquenesshtml5有哪些新特性、移除了那些元素?如何處理HTML5新標(biāo)簽的瀏覽器兼容問題?如何區(qū)分 HTML 和 HTML5? What"s new html5, removing those elements? How to deal with a new label HTML5 browser compatibility problems? How to distinguish between HTML and HTML5?HTML5 現(xiàn)在已經(jīng)不是 SGML 的子集,主要是關(guān)于圖像,位置,存儲,多任務(wù)等功能的增加。
拖拽釋放(Drag and drop) API
語義化更好的內(nèi)容標(biāo)簽(header,nav,footer,aside,article,section)
音頻、視頻API(audio,video)
畫布(Canvas) API
地理(Geolocation) API
本地離線存儲 localStorage 長期存儲數(shù)據(jù),瀏覽器關(guān)閉后數(shù)據(jù)不丟失;
sessionStorage 的數(shù)據(jù)在瀏覽器關(guān)閉后自動刪除表單控件,calendar、date、time、email、url、search
新的技術(shù)webworker, websocket, Geolocation
移除的元素
純表現(xiàn)的元素:basefont,big,center,font, s,strike,tt,u;
對可用性產(chǎn)生負(fù)面影響的元素:frame,frameset,noframes;
支持HTML5新標(biāo)簽:
IE8/IE7/IE6支持通過document.createElement方法產(chǎn)生的標(biāo)簽,
可以利用這一特性讓這些瀏覽器支持HTML5新標(biāo)簽,瀏覽器支持新標(biāo)簽后,還需要添加標(biāo)簽?zāi)J(rèn)的樣式:
當(dāng)然最好的方式是直接使用成熟的框架、使用最多的是html5shim框架
HTML5 now is not a subset of SGML, mainly to increase with respect to the image, location, storage, multi-tasking and other features.
Drag release (Drag and drop) API
content better label (header, nav, footer, aside, article, section)
audio, video, API (audio, video)(Canvas) API
(Geolocation) API
Local localStorage offline storage for long term storage of data, the browser is closed after data is not lost;
sessionStorage of data after the browser is closed automatically deletecontrols, calendar, date, time, email, url, search
WebWorker new technologies, websocket, GeolocationRemove The elements of
the element of pure performance: basefont, big, center, font, s, strike, tt, u;
adversely affect the availability of the elements of: frame, frameset, noframes;
support HTML5 new label:
IE8 / IE7 / IE6 support through document.createElement method of producing labels,
use this feature to allow these browsers support HTML5 new label,
after the browser to support the new label, you also need to add tags default style:
Of course, the best way is the direct use of mature framework, use the most is html5shim framework
如何區(qū)分: DOCTYPE聲明新增的結(jié)構(gòu)元素功能元素
How to distinguish: DOCTYPE declaration new structural elements functional elements iframe advantages and disadvantages?
iframe的優(yōu)缺點?1.`iframes clog Onload event of the main page;
Instant content is empty, it takes time to load
no semantics
如何實現(xiàn)瀏覽器內(nèi)多個標(biāo)簽頁之間的通信? How to communicate within the browser between multiple tabs?調(diào)用localstorge、cookies等本地存儲方式 Call localstorge, cookies and other local storage線程與進程的區(qū)別 The difference between threads and processes一個程序至少有一個進程,一個進程至少有一個線程. 線程的劃分尺度小于進程,使得多線程程序的并發(fā)性高。 另外,進程在執(zhí)行過程中擁有獨立的內(nèi)存單元,而多個線程共享內(nèi)存,從而極大地提高了程序的運行效率。 線程在執(zhí)行過程中與進程還是有區(qū)別的。每個獨立的線程有一個程序運行的入口、順序執(zhí)行序列和程序的出口。但是線程不能夠獨立執(zhí)行,必須依存在應(yīng)用程序中,由應(yīng)用程序提供多個線程執(zhí)行控制。 從邏輯角度來看,多線程的意義在于一個應(yīng)用程序中,有多個執(zhí)行部分可以同時執(zhí)行。但操作系統(tǒng)并沒有將多個線程看做多個獨立的應(yīng)用,來實現(xiàn)進程的調(diào)度和管理以及資源分配。這就是進程和線程的重要區(qū)別。 A program has at least one process, a process has at least one thread. divided scale smaller than the thread process, making multi-threaded program concurrency high. In addition, the process has a separate memory unit in the implementation process, and multiple threads shared memory, thereby greatly enhancing the operational efficiency of the program. Threads in the implementation process and the process is still a difference. Each has a separate thread running entry, exit sequence and procedure execution order. But the thread is not able to perform independent, it must exist according to the application, providing multiple threads of execution is controlled by the application. From a logical point of view, the significance of a multi-threaded application, there are a plurality of the operative part can execute simultaneously. But the operating system is not seen as multiple threads multiple independent applications to achieve scheduling and management and resource allocation process. This is an important distinction between processes and threads.你如何對網(wǎng)站的文件和資源進行優(yōu)化? How do you document and optimize resource site?期待的解決方案包括: 文件合并 文件最小化/文件壓縮 使用 CDN 托管 緩存的使用(多個域名來提供緩存) 其他 Expect solutions include: file merge file Minimize / file compression using CDN hosted cache usage (multiple domain names to provide caching) Other請說出三種減少頁面加載時間的方法。 Please name three reduce page load time.1.優(yōu)化圖片 2.圖像格式的選擇(GIF:提供的顏色較少,可用在一些對顏色要求不高的地方) 3.優(yōu)化CSS(壓縮合并css,如margin-top,margin-left...) 4.網(wǎng)址后加斜杠(如www.campr.com/目錄,會判斷這個“目錄是什么文件類型,或者是目錄。) 5.標(biāo)明高度和寬度(如果瀏覽器沒有找到這兩個參數(shù),它需要一邊下載圖片一邊計算大小,如果圖片很多,瀏覽器需要不斷地調(diào)整頁面。這不但影響速度,也影響瀏覽體驗。 當(dāng)瀏覽器知道了高度和寬度參數(shù)后,即使圖片暫時無法顯示,頁面上也會騰出圖片的空位,然后繼續(xù)加載后面的內(nèi)容。從而加載時間快了,瀏覽體驗也更好了。) 6.減少http請求(合并文件,合并圖片)。Optimize image
Select the image format (GIF: color offered fewer colors used in some of the less demanding areas)
Optimize CSS (compression merge css, such as margin-top, margin-left ... )
slash site (eg www.campr.com/ directory, will determine the "directory what file type or directory.)
indicate the height and width (if the browser does not find these two parameters, It needs to calculate the size of one side while downloading pictures, if the picture a lot, browsers need to constantly adjust the page. This will not only affect the speed, but also affect browsing experience.
When the browser know the height and width parameters, even if the picture is temporarily unable to display the page will make pictures of space, and then continue to load the contents back thus loading time faster browsing experience is better.)To reduce http requests (merge files, merge pictures).
你都使用哪些工具來測試代碼的性能? Which tools you use to test the performance of the code?Profiler, JSPerf(http://jsperf.com/nexttick-vs-setzerotimeout-vs-settimeout), Dromaeo什么是 FOUC(無樣式內(nèi)容閃爍)?你如何來避免 FOUC? What is FOUC (free style content flicker)? How do you avoid FOUC?FOUC - Flash Of Unstyled Content 文檔樣式閃爍 而引用CSS文件的@import就是造成這個問題的罪魁禍?zhǔn)住E會先加載整個HTML文檔的DOM,然后再去導(dǎo)入外部的CSS文件,因此,在頁面DOM加載完成到CSS導(dǎo)入完成中間會有一段時間頁面上的內(nèi)容是沒有樣式的,這段時間的長短跟網(wǎng)速,電腦速度都有關(guān)系。 解決方法簡單的出奇,只要在之間加入一個或者