[轉貼] 解決 Chrome 播 Youtube lag

出至:http://forum8.hkgolden.com/view.aspx?message=4823251&highlight_id=342776

適用症狀:
用Chrome播Youtube會有雜音或頓頓的、聲音跟不上畫面的不同步情況等等,或者是瀏覽Flash網頁的時候會很卡、很頓。並且以上症狀換另外一個瀏覽器就沒事。

解法:
步驟1. 網址列輸入chrome://plugins/,開啟詳細資訊
步驟2. 停用chrome內建的flash播放元件

## 看來是 chrome 自帶的 flashplayer 搞鬼。

jsonp 跨站原則上僅能以「get」模式傳遞資料

From: http://stackoverflow.com/questions/2699277/post-data-to-jsonp

不可能用一個非同步的「post」模式,在一個跨網域的服務上,由於原則上的限定。所以僅能以「get」模式傳資料到跨網域服務。

範例網頁:http://xyz.cinc.biz/2013/02/jquery-jsonp.html

It is not possible to do an asynchronous POST to a service on another domain, due to the (quite sensible) limitation of the same origin policy. JSON-P only works because you’re allowed to insert<script> tags into the DOM, and they can point anywhere.

You can, of course, make a page on another domain the action of a regular form POST.

Edit: There are some interesting hacks out there if you’re willing to go to a lot of effort inserting hidden<iframe>s and mucking about with their properties.

Javascript Char Codes (Key Codes)

From: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

Javascript is often used on the browser client side to perform simple tasks that would otherwise require a full postback to the server. Many of those simple tasks involve processing text or characters entered into a form element on a web page, and it is often necessary to know the javascript keycode associated with a character. Here is a reference.

Key Code
backspace 8
tab 9
enter 13
shift 16
ctrl 17
alt 18
pause/break 19
caps lock 20
escape 27
page up 33
page down 34
end 35
home 36
left arrow 37
up arrow 38
right arrow 39
down arrow 40
insert 45
delete 46
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
a 65
b 66
c 67
d 68
Key Code
e 69
f 70
g 71
h 72
i 73
j 74
k 75
l 76
m 77
n 78
o 79
p 80
q 81
r 82
s 83
t 84
u 85
v 86
w 87
x 88
y 89
z 90
left window key 91
right window key 92
select key 93
numpad 0 96
numpad 1 97
numpad 2 98
numpad 3 99
numpad 4 100
numpad 5 101
numpad 6 102
numpad 7 103
Key Code
numpad 8 104
numpad 9 105
multiply 106
add 107
subtract 109
decimal point 110
divide 111
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123
num lock 144
scroll lock 145
semi-colon 186
equal sign 187
comma 188
dash 189
period 190
forward slash 191
grave accent 192
open bracket 219
back slash 220
close braket 221
single quote 222

CSS 背景色漸層設定 linear-gradient

From: https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient

HTML

<div id='background_div'
style='width:200px;height:200px;border:1px solid black;padding:5px;'>
我的背景色是漸層喔!
</div>

CSS

#background_div {
background-color: #F07575; /* fallback color if gradients are not supported */
background-image: -webkit-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For Chrome and Safari */
background-image: -moz-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Fx (3.6 to 15) */
background-image: -ms-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For pre-releases of IE 10*/
background-image: -o-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Opera (11.1 to 12.0) */
background-image: linear-gradient(to bottom, hsl(0, 80%, 70%), #bada55); /* Standard syntax; must be last */
}

範例結果:
http://jsfiddle.net/UzKX2/

Paused in debugger in chrome?

From: http://stackoverflow.com/questions/12833514/paused-in-debugger-in-chrome

When debugging in chrome, the scripts are always paused in the debugger even if there are no break points set, and if the the pause is un-paused, it again pauses itself.

What can be done?

One possible cause, it that you’ve enabled the “pause on exceptions" (the little stop-sign shaped icon with the pause (||) symbol with in in the lower left of the window). Try clicking that back to the off/grey state (not red nor blue states) and reload the page.

原來是我不小心誤按成了「例外暫停模式」,一直以為 chrome 怎麼在我除錯時一直動不動就自已暫停,還以為它是秀抖了嗎?

[轉貼] 如何取得網頁元素的 “scrollbar" 右移最大值 ,scrollWidth、clientWidth 定義

來源:http://www.360doc.com/content/11/1025/09/432969_158877433.shtml ,http://stackoverflow.com/questions/5138373/how-do-i-get-the-max-value-of-scrollleft

如何取得網頁元素的 “scrollbar" 右移最大值

下面這行就可得知元素的 “scrollbar" 右移的最大值。

var maxScrollLeft = element.scrollWidth – element.clientWidth;

scrollHeight: 獲取對象的滾動高度。
scrollLeft: 設置或獲取位於對象左邊界和窗口中目前可見內容的最左端之間的距離
scrollTop: 設置或獲取位於對象最頂端和窗口中可見內容的最頂端之間的距離
scrollWidth: 獲取對象的滾動寬度

offsetHeight: 獲取對象相對於版面或由父坐標 offsetParent 屬性指定的父坐標的高度
offsetLeft: 獲取對象相對於版面或由 offsetParent 屬性指定的父坐標的計算左側位置
offsetTop: 獲取對象相對於版面或由 offsetTop 屬性指定的父坐標的計算頂端位置
offsetWidth: 是對象的可見寬度,包滾動條等邊線,會隨窗口的顯示大小改變

event.clientX 相對文檔的水平座標
event.clientY 相對文檔的垂直座標
clientWidth: 是對象可見的寬度,不包滾動條等邊線,會隨窗口的顯示大小改變。
clientHeight: 都認為是內容可視區域的高度,也就是說頁面瀏覽器中可以看到內容的這個區域的高度,一般是最後一個工具條以下到狀態欄以上的這個區域,與頁面內容無關。 內容來自17jquery

event.offsetX 相對容器的水平坐標
event.offsetY 相對容器的垂直坐標
document.documentElement.scrollTop 垂直方向滾動的值
event.clientX+document.documentElement.scrollTop 相對文檔的水平座標+垂直方向滾動的量 一起

以上主要指IE之中,FireFox差異如下:
IE6.0、FF1.06+:
clientWidth = width + padding
clientHeight = height + padding
offsetWidth = width + padding + border
offsetHeight = height + padding + border
IE5.0/5.5:
clientWidth = width – border
clientHeight = height – border
offsetWidth = width
offsetHeight = height

(需要提一下:CSS中的margin屬性,與clientWidth、offsetWidth、clientHeight、offsetHeight均無關) 1

[轉貼] a:link / a:visited / a:hover / a:active 使用上的順序

來源:http://www.dotblogs.com.tw/joysdw12/archive/2011/01/07/20651.aspx

在網站超連結效果使用上常常用到 a:link / a:visited / a:hover / a:active 這幾個css屬性。但是在使用上必須注意到的是這些屬性是有順序的。

使用上的順序如下:

        /* 未連結 */
        a:link
        {
            color: #000000;
        }
        /* 已連結過 */
        a:visited
        {
            color: #FF0000;
        }
        /* 滑鼠移至連結 */
        a:hover
        {
            color: #00FF00;
        }
        /* 選擇的連結 */
        a:active
        {
            color: #0000FF;
        }
 

a:hover 需放置在 a:link 跟 a:visited 之後,則 a:active 放置在 a:hover 之後。

轉貼:Javascript 刷新頁面的幾種方法

來源:http://blog.yam.com/htshboy/article/12692684

Javascript 刷新頁面的幾種方法

1   history.go(0)
2   location.reload()
3   location=location
4   location.assign(location)
5   document.execCommand(‘Refresh’)
6   window.navigate(location)
7   location.replace(location)
8   document.URL=location.href

自動刷新頁面的方法

1.頁面自動刷新:把如下代碼加入<head>區域中
<meta http-equiv="refresh" content="20″>
其中20指每隔20秒刷新一次頁面.

2.頁面自動跳轉:把如下代碼加入<head>區域中
<meta http-equiv="refresh" content="20;url=http://www.wyxg.com">
其中20指隔20秒後跳轉到http://www.wyxg.com頁面

3.頁面自動刷新js版
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout(‘myrefresh()’,1000); //指定1秒刷新一次
</script>

ASP.NET如何輸出刷新父窗口腳本語句

1.  this.response.write(“<script>opener.location.reload();</script>");

2.  this.response.write(“<script>opener.window.location.href = opener.window.location.href;</script>");

3.  Response.Write(“<script language=javascript>opener.window.navigate(“你要刷新的頁.asp");</script>")

JS刷新框架的腳本語句

//如何刷新包含該框架的頁面用
<script language=JavaScript>
parent.location.reload();
</script>

//子窗口刷新父窗口
<script language=JavaScript>
self.opener.location.reload();
</script>
( 或 <a href="javascript:opener.location.reload()">刷新</a>   )

//如何刷新另一個框架的頁面用
<script language=JavaScript>
parent.另一FrameID.location.reload();
</script>

如果想關閉窗口時刷新或者想開窗時刷新的話,在<body>中調用以下語句即可。

<body onload="opener.location.reload()"> 開窗時刷新
<body onUnload="opener.location.reload()"> 關閉時刷新

<script language="javascript">
window.opener.document.location.reload()
</script>

[轉貼] Asp.Net Cookie 讀取中文變亂碼的解決方法(IE8 會發生 chrome 卻不會發生)

出至:http://tgw1029.blogspot.tw/2010/04/aspnet-cookie.html

Asp.Net -Cookie讀取中文變亂碼的解決方法

有時我的可能因為特別需求,必須使用Cookie來存放簡短的中文字。但中文字的編碼與Cookie預設的編碼方式不同,因此必須先行在URL傳輸過程中經過一道編碼、解碼的程序,才不會發生中文字在Cookie中讀取出來為亂碼的情況。

一般建立Cookie的寫法為:

Dim cookie As New HttpCookie(“UserInfo")
cookie.Values.Add(“Login", “OK")
cookie.Values.Add(“No", dr(“員工編號"))
cookie.Values.Add(“Name", (dr(“員工姓名"))
Response.Cookies.Add(cookie)

由於其中"Name"的Cookie內容存放的是中文字員工姓名,讀取時使用Request.Cookies(“UserInfo")(“Name")後,會發現讀到的中文已經變為亂碼

我們將原本的寫法加入HttpUtility.UrlEncode(編碼)HttpUtility.UrlDecode(解碼),在URL中傳輸而進行編碼的字串轉換來解決亂碼的問題。修改後程式碼如下:

建立Cookie時編碼:

Dim cookie As New HttpCookie(“UserInfo")
cookie.Values.Add(“Login", “OK")
cookie.Values.Add(“No", dr(“員工編號"))
cookie.Values.Add(“Name", HttpUtility.UrlEncode(dr(“員工姓名")))
Response.Cookies.Add(cookie)

讀取時解碼:

HttpUtility.UrlDecode(Request.Cookies(“UserInfo")(“Name"))