[轉貼] 解決 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 搞鬼。

廣告

Check for Ajax request in Code Igniter

From: http://stackoverflow.com/questions/11687180/check-for-ajax-request-in-code-igniter

Q:

I’m in a PHP script and I want to check whether the request is an Ajax request. (basically so as NOT to allow direct script access, other than Ajax call that is…)

So, I’m defining IS_AJAX somewhere in the main index.php file :

define('IS_AJAX', 
       isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 
       strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

And then checking it at the top of my script :

if (!IS_AJAX) exit('No direct script access allowed');

Since I’m new to CodeIgniter, I’m not really sure…

  • Is there any such built-in functionality?
  • Is there a more… elegant way to do it?

A:

You can use $this->input->is_ajax_request() from the input class:

if (!$this->input->is_ajax_request()) {
    exit(‘No direct script access allowed’);
}

緩動函數(easings)速查表

緩動函數指定動畫效果在執行時的速度,使其看起來更加真實。

現實物體照著一定節奏移動,並不是一開始就移動很快的。當我們打開抽屜時,首先會讓它加速,然後慢下來。當某個東西往下掉時,首先是越掉越快,撞到地上後回彈,最終才又碰觸地板。

本頁可以在每次你需要時,幫助你找到想要的緩動函數。

http://api.jqueryui.com/easings/ 此頁也有相同的範例說明。

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.

jsonp 測試頁面 前端 html 及後端 php 範例

HTML:

<html>
<head>
<META HTTP-EQUIV="CONTENT-TYPE" 
CONTENT="text/html; charset=UTF-8">
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.js'></script>
<script type='text/javascript'>
function show_msg(msg){
	alert(msg);
}
$(function(){
	$.ajax({
		type:'get',
		async:false,
		crossDamain:true,
		cache:false,
		url:'http://carbonfootprint.toyoink-ct.com.tw/carbonfootprint/login_valid',
		dataType:'jsonp',
		jsonCallback:'show_msg',
		data:{account:'jerry',passwd:'justdoit'}
	});
});
</script>
</head>
<body>
</body>
</html>

PHP:

    public function login_valid(){
        $account=$this->input->get('account');
        $passwd=$this->input->get('passwd');
        $query=$this->db->query("select * from carbon_passwd where id='{$account}' and passwd='{$passwd}';");
        if($query->num_rows()>0){
            $this->session->set_userdata($query->row(1));
            //print_r($this->session->all_userdata());
            echo "show_msg('密碼對了^^');";
        }
        else{
            echo "show_msg('你打的帳號:{$account},密碼:{$passwd}不對喔!!');";
        }
    }

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/

CSS 如何指定顏色 (16進位值、RGB、RGBA、HSL、HSLA)

From: http://www.w3schools.com/cssref/css_colors_legal.asp

Hexadecimal Colors

Hexadecimal color values are supported in all major browsers.

A hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and BB (blue) hexadecimal integers specify the components of the color. All values must be between 0 and FF.

For example, the #0000ff value is rendered as blue, because the blue component is set to its highest value (ff) and the others are set to 0.

Example

Define different HEX colors:

#p1 {background-color:#ff0000;} / * red */
#p2 {background-color:#00ff00;} / * green */
#p3 {background-color:#0000ff;} / * blue */

RGB Colors

RGB color values are supported in all major browsers.

An RGB color value is specified with: rgb(red, green, blue). Each parameter (red, green, and blue) defines the intensity of the color and can be an integer between 0 and 255 or a percentage value (from 0% to 100%).

For example, the rgb(0,0,255) value is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.

Also, the following values define equal color: rgb(0,0,255) and rgb(0%,0%,100%).

Example

Define different RGB colors:

#p1 {background-color:rgb(255,0,0);} / * red */
#p2 {background-color:rgb(0,255,0);} / * green */
#p3 {background-color:rgb(0,0,255);} / * blue */

RGBA Colors

RGBA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

RGBA color values are an extension of RGB color values with an alpha channel – which specifies the opacity of the object.

An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Example

Define different RGB colors with opacity:

#p1 {background-color:rgba(255,0,0,0.3);} / * red with opacity */
#p2 {background-color:rgba(0,255,0,0.3);} / * green with opacity */
#p3 {background-color:rgba(0,0,255,0.3);} / * blue with opacity */

HSL Colors

HSL color values are supported in IE9+, Firefox, Chrome, Safari, and in Opera 10+.

HSL stands for hue, saturation, and lightness – and represents a cylindrical-coordinate representation of colors.

An HSL color value is specified with: hsl(hue, saturation, lightness).

Hue is a degree on the color wheel (from 0 to 360) – 0 (or 360) is red, 120 is green, 240 is blue. Saturation is a percentage value; 0% means a shade of gray and 100% is the full color. Lightness is also a percentage; 0% is black, 100% is white.

Example

Define different HSL colors:

#p1 {background-color:hsl(120,100%,50%);} / * green */
#p2 {background-color:hsl(120,100%,75%);} / * light green */
#p3 {background-color:hsl(120,100%,25%);} / * dark green */
#p4 {background-color:hsl(120,60%,70%);} / * pastel green */

HSLA Colors

HSLA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

HSLA color values are an extension of HSL color values with an alpha channel – which specifies the opacity of the object.

An HSLA color value is specified with: hsla(hue, saturation, lightness, alpha), where the alpha parameter defines the opacity. The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Example

Define different HSL colors with opacity:

#p1 {background-color:hsla(120,100%,50%,0.3);} / * green with opacity */
#p2 {background-color:hsla(120,100%,75%,0.3);} / * light green with opacity */
#p3 {background-color:hsla(120,100%,25%,0.3);} / * dark green with opacity */
#p4 {background-color:hsla(120,60%,70%,0.3);} / * pastel green with opacity */