原文網址:http://msdn.microsoft.com/zh-tw/ie/gg712396.aspx

 

 

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://blogs.msdn.com/b/ericsk/archive/2011/03/15/internet-explorer-9-ie9.aspx

以下原文轉載
--------------------------------------------------------------------------------------------

Internet Explorer 9 (以下以 IE9 稱之)終於釋出正式版本了,只要是使用 Windows Vista、Windows 7 及 Windows Server 2008 的用戶皆可以升級這個最新版本的瀏覽器。

IE9 最大的特色就是開始支援部份 HTML5 及 CSS3 的規格標準,對於網頁開發者來說,除了可以藉用 IE9 來嚐試新的網頁標準之外,更可以拿它來作為與前幾代 IE 的相容性檢查的的工具,一般的使用者也可以利用這個功能來試著瀏覽只能在舊版本 IE 瀏覽的網頁。以下分別為這兩個族群的使用者來簡單介紹一下「相容性檢視」這個功能。

一般使用者

如果開始使用 IE9 之後,發現原本看得好好的網頁版面突然亂掉了,在經過幾次重新整理(按 Ctrl + F5)後還是不見改善的話,可以嚐試使用相容性檢視的功能,如果網址列上出現這樣的圖案:


網址列上的相容性檢視按鈕

那就可以試著按下,看看網頁是不是排版就正常許多了呢。如果你不確定自己現在是用哪一個版本的 IE 瀏覽器來檢視網頁的話,也可以按下鍵盤上的 F12 功能鍵,啟動開發人員工具,這時便可以確定目前是用哪一個模式來瀏覽網頁了。


利用開發人員工具切換瀏覽器模式

如此一來應該可以解決許多網頁排版亂掉的問題。而更重要的是,如果已經使用 IE9 了,卻無法瀏覽(或是出現不支援字樣)宣稱利用 HTML5 相關技術的網頁時,也別忘了利用這個工具看看文件模式是否已經切換至「Internet Explorer 9 標準

 

網頁開發者

身為網頁開發者,在知道 IE9 有這樣相容性檢視的功能後,在網頁原始碼中要注意幾個部份,才不會讓使用者使用了錯誤的瀏覽模式來瀏覽網頁。

首先要注意的是,網頁原始碼中,第一行一定要加上正確的 doctype ,否則 IE 會認為這是非常舊時代的網頁,並且會自動以「Quirks 模式」來顯示網頁,這除了會造成版面整個大亂(因為 CSS 計算區塊大小、位移等問題)之外,也會讓一些 JavaScript 物件的數值不如預期。所以網頁一定要根據使用的網頁標準,加入正確的 doctype 宣告。以下是幾個常用的網頁標準:

  • HTML5

    <!DOCTYPE html>

  • HTML 4.01

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

  • XHTML 1.1

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

這樣就能夠確保 IE 瀏覽器會以標準模式來顯示網頁。

另外,如果網頁原本已經針對 IE7 或是 IE8 而特別調整過,一時之間沒有時間或資源可以重新設計網頁的話,也可以在 <head> 及 </head> 標籤之間,加上:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">

這可以告訴 IE 瀏覽器使用 IE7 模式來顯示網頁,當然你也可以將它改成EmulateIE8EmulateIE9,但不能模擬 IE6 就是了 :P

最後,在設計 HTML5 的網頁時,也別忘了檢查 IE9 的文件模式是不是切換至 Internet Explorer 9 標準模式,否則寫了半天還不能用 <canvas><video> 等新標籤,還很難找出錯誤在哪裡呢!

 

也可參考IE9相容性操作手冊

 

yoonow 發表在 痞客邦 留言(1) 人氣()

原文網址:http://www.dannyherran.com/2011/02/detect-mobile-browseruser-agent-with-php-ipad-iphone-blackberry-and-others/

以下原文轉載
----------------------------------------------------------------------------------------------

Detect mobile browser/user agent with PHP (iPad, iPhone, Android, BlackBerry, WP7 and others)

With all this load of smartphones and tablets, it is mandatory for us as developers to optimize our content as much as possible so everybody can see it, no matter what device they are using. This is why I wrote a small but powerful function to properly detect a wide range of mobile devices and redirect to an special content accordingly.

Lets take a look:

Code:
1
2
3
4
5
6
7
8
function detect_mobile()
{
    if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|sagem|sharp|sie-|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT']))
        return true;
 
    else
        return false;
}

This function can detect most (if not all) of all the standard “dumb” phones, smartphones, including the iPhone, iPad, Android and Windows Phone 7. Lets say you want to redirect your users to your blog if they are accessing your home page from a mobile device:

Code:
1
2
3
4
$mobile = detect_mobile();
 
if($mobile === true)
    header('Location: blog');

Nice and easy!

Changelog:
24/03/2011 – Updated for Android
25/04/2011 – Updated for Windows Phone 7
23/05/2011 – Updated for iPod Touch
16/01/2012 – Rewritten, shortened. Deleted unnecesary checks. Added Windows CE support.

 By  · on February 2, 2011 at 6:52 pm · 63 comments

Tags:        

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://blog.roodo.com/pokey/archives/16354565.html

以下轉載原文

-----------------------------------------------------------------------------------

最近的一個Case必須要套用Barcode,
但是距離我還有印象的Barcode年代,已經過了好多好多個年,早就已經忘光了。
在這裡簡單分享我找到的Barcode for PHP,以及套用的步驟。

這篇介紹的只是我找到,覺得好理解,套用起來不麻煩的組件。
而且支援的格式相當多,
唯一缺點是沒辦法很彈性的去設定Barcode的長寬。
不過趕時間不想去Try其他人提供的Code的話,
其實Barcode Generator程式架構寫的還OK,去翻翻他的原始碼稍微修改一下也不太花時間。


 

 
我使用的是來自PHP Classes網站的BarcodeGenerator。
剛剛才發現居然版號是2005年. . . 但是其實不要緊。
因為他只是使用GD去產生黑白色塊,而條碼的規則早就已經制定好兩萬多年,不用去計較年份。

 Barcode_Generator-2005-09-08.zip 
以上這是原始檔名,我只提供
 PHP Classes 的連結,要下載需要註冊會員。
如果經常要使用PHP當開發語言,註冊一下吧,他有很豐富的Classes資料庫,
由一堆人因應各種需求寫完程式以後分享給大家使用。For Freeeeeee....

套用開始:

1.請記得開啟PHP的GD功能
不是自建主機,請聯絡你的虛擬主機提供商,
自建主機的,請自己去找找怎麼開啟,這樣才學得會. . .  其實是我也不太懂,都是拜Google大神 
2.打開壓縮檔有以下檔案結構


Class資料夾: 
放置一堆各式各樣類型的code規則。留下你需要用的就好,像我要使用的是ean13。就留下ean13.barcode.php。記得別刪到一些用來產生圖片或填色的php檔,安全的作法有兩種。刪一個,就去測試看看還能不能正常使用;最保險的就是. . . 別刪。
Html資料夾: 
產出對應Code格式的頁面,也是一樣留下你需要用的就好,可以好好瘦身。也是同上,別刪到產圖的檔案,例如image.php。
根目錄資料: 
一堆不重要的碎擋,可以D掉。根目錄留index.php即可。
留下index.php只是要介紹他怎麼產出,了解他出圖規則後,就可以砍了。

3.測試Barcode
丟上你的測試環境後,譬如丟到/www/barcode。
鍵入你的網址 http://localhost/barcode/index.php
可以看到以下畫面。

Type: 
Codabar,Code 11/39/93/128, EAN 8/13/ISBN, Interleaved 2 of 5, Standard 2 of 5, MSI, UPC A/E/E2D/E5D, PostNet, Other Code。請自己選擇合適的,當然有些條碼其實很少人使用,可能多數的條碼機無法辨識,請先確認格式。
Output: 
圖片輸出的格式。PNG/JPG。
Thickness:  
條碼的高度,看起來單位是pixel。
Resolution: 
 你的粗細. . .  條碼的粗細。會影響整個條碼圖式的寬度。僅分三種size。
Font Size: 
條碼下方數字的大小。也可以不顯示。但是還是建議顯示,畢竟調碼有可能損壞,就必須透過人眼辨識系統來判斷了。
Text: 
條碼號。請根據不同的編碼格式輸入數字,他有基本防呆可以幫你偵錯。

OK以後按下Generator就會出現啦。沒出現的話請檢察GD是否啟動,方法? 請找Google。

產生出來的圖檔我們按右鍵,去看看他的圖片路徑。

圖片路徑: 
http://localhost/barcode/html/image.php?code=ean13&o=1&t=30&r=2&text=123456789012&f=1&a1=&a2=
很明顯的這就是我們剛剛選擇的參數。
直接將參數複製在網址列上,只有IE可以正常顯示,FireFox和Chrome會顯是一堆亂碼。
但是應用在網頁中,以圖片方式產出,不會有這個問題的。

我們開始套用吧。
1. 首先準備一張圖,沒有圖沒關係,我提供一張給你。檔名diablo.jpg


2.預定要輸出Barcode的網頁。檔名barcode_output.php
輸入以下程式碼。
<table width="650" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td background="diablo.jpg" width="650" height="650" valign="top" align="left">
            <div style="padding:3px 3px 3px 3px;margin:165px 6px 6px 20px;background-color:#F0F0F0;width:110px;text-align:center;">
                <img src="html/image.php?code=ean13&o=2&t=20&r=1&text=123456789012&f=1&a1=&a2=" alt="Error? Can\'t display image!" />
            </div>
        </td>
    </tr>
</table>


我們把圖片壓在表格的背景圖中。然後文字對齊讓他靠右靠上。
在div的style中設定一些邊框,讓barcode看起來不要太死。
接下來裝上我們的barcode <img>。
這邊比較特別,img的src是指向一個php檔,也就是我們剛剛對圖片複製的那串連結。
這邊就可以透過程式去產出你的text(條碼編號)甚至是自訂的寬度高度設定。

就這樣就完成了。可以印一印拿去賣了。

別抓我,這只是教學. . . 。

謝謝收看。

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://halladay5364.pixnet.net/blog/post/1932168-php%E8%A3%BD%E4%BD%9C%E4%B8%80%E7%B6%AD%E6%A2%9D%E7%A2%BC

以下轉載原文

---------------------------------------------------------------------------------

因為要直接從程式產生一維條碼,所以要靠自己寫

看了很多人寫的一維條碼的資料,終於看懂了

大部分超商都是使用" EAN-13 "

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

EAN-13碼(European Article Number,歐洲商品條碼)是1977年由歐洲十二個工業國家所共同發展出來的一種條碼系統,其後逐漸變成國際性的條碼系統,一般多用作商品標示條碼。其編碼特性如下: 

1. 資料只能為0~9之數字計12個,連同檢查碼共13碼。資料中包括國家代碼3碼、廠商代碼4碼、產品代碼5碼,為一種專用於商品標示的條碼。 
2. 編碼結構為〔護線+6個左資料碼+中線+5個右資料碼+檢查碼+護線〕,共佔119條線。其中在畫線時,護線和中線在下方均略長於資料碼,以便肉眼能明顯區分,但對於條碼機閱讀時並無差異。 
3. 左資料的編碼方式有A、B兩組之分,而資料的第一碼隱藏在左資料碼的編碼方式,故實際只編出12碼。以下為左資料依首碼所對應使用的編碼方式:

0 AAAAAA
1 AABABB
2 AABBAB
3 AABBBA
4 ABAABB
5 ABBAAB
6 ABBBAA
7 ABABAB
8 ABABBA
9 ABBABA 

4. 左資料的編碼方式,A組編碼為:

0 0001101
1 0011001
2 0010011
3 0111101
4 0100011
5 0110001
6 0101111
7 0111011
8 0110111
9 0001011

B組編碼為:

0 0100111
1 0110011
2 0011011
3 0100001
4 0011101
5 0111001
6 0000101
7 0010001
8 0001001
9 0010111

以上各位元0為白,1為黑。 

5. 護線固定為101,中線固定為01010,各位元0為白,1為黑。 
6. 右資料編碼方式固定為:

0 1110010
1 1100110
2 1101100
3 1000010
4 1011100
5 1001110
6 1010000
7 1000100
8 1001000
9 1110100

各位元0為白,1為黑。

驗證碼算法:

 

 國家代號(3位數) 中華民國的國家代號為471。
▲ 廠商代號(6位數) 由本會核發給廠商6位數的廠商代號。
 商品代號(3位數) 由廠商自行編定,按一物一號的原則,不同的 商品賦予不同的序號。(包裝、尺寸、顏色、 材質等不同,應視為不同的商品)
 檢核碼 按"10法則"的公式計算得之。
 
檢核碼計算方式
 
國家代號
廠商代號
商品
代號



位數
13
12
11
10
9
8
7
6
5
4
3
2
1
條碼編號
4
7
1
1
2
3
4
5
6
0
0
1
 
步驟一
偶位數數值相加乘3
7+1+3+5+0+1=17,17×3=51
步驟二
奇位數數值相加
4+1+2+4+6+0=17
步驟三
將步驟一與步驟三之和相加
51+17=68
步驟四
以10減去步驟三總和之個
位數,所得即為檢核碼
10-8=2→檢核碼
若步驟三總和的個位數為"0",
檢核碼即為"0"

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

實際範例:  4 714947 000196

從 開頭 471 可以得知 是台灣條碼

而從 4 知道 要用ABAABB (左資料的編碼方式有A、B兩組之分,而資料的第一碼隱藏在左資料碼的編碼方式)

 

  ABAABB  
4    
7 0111011 A
1 0110011 B
4 0100011 A
9 0001011 A
4 0011101 B
7 0010001 B
0 1110010  
0 1110010  
0 1110010  
1 1100110  
9 1110100  
6 1010000  
   

0為白

1為黑。 

依照以上的來畫線 就可以畫出來了。

編碼結構為〔護線+6個左資料碼+中線+5個右資料碼+檢查碼+護線〕,共佔119條線。其中在畫線時,護線和中線在下方均略長於資料碼,以便肉眼能明顯區分,但對於條碼機閱讀時並無差異。

護線固定為101,中線固定為01010,各位元0為白,1為黑。

將2邊加上

101 + 714947 + 01010 + 000196 + 101  (粗體為十進位,其他為二進位,請自行轉換十進位)

 

ex: 101011101101100110100011000101100010110011101001000101010111001011100101110010110011011101001010000

按照上面 0空白 1畫線 就可以畫出

一維條碼 


 

 

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

參考:

http://www.programmer-club.com.tw/ShowSameTitleN/general/7269.html

http://www.vixual.net/blog/archives/89

http://adc.cm.nsysu.edu.tw/barcode/1d_def.htm

http://tw.knowledge.yahoo.com/question/question?qid=1105052607348

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://bojack.pixnet.net/blog/post/3780245-%E5%88%A9%E7%94%A8-php-%E7%A8%8B%E5%BC%8F%E7%94%A2%E7%94%9F%E6%A2%9D%E7%A2%BC

以下轉載原文

--------------------------------------------------------------------------------

在 EcStart 論壇 看這個實用的功能,原則上 PHP 要有支援 GD 的功能就可以了!

使用的方式很簡單 ... 範例語法如下

<IMG SRC="barcode.php?barcode=HELLO&quality=75">
<IMG SRC="barcode.php?barcode=123456&width=320&height=200">


程式碼在這個地方

---------------------------------------------------------------------------------

以下轉載程式碼

<?php
/*===========================================================================*/
/*      PHP Barcode Image Generator v1.0 [9/28/2000]
        Copyright (C)2000 by Charles J. Scheffold - cs@wsia.fm

        This code is hereby released into the public domain.
        Use it, abuse it, just don't get caught using it for something stupid.

        The only barcode type currently supported is Code 3 of 9. Don't ask about 
        adding support for others! This is a script I wrote for my own use. I do 
        plan to add more types as time permits but currently I only require 
        Code 3 of 9 for my purposes. Just about every scanner on the market today
        can read it.

        PARAMETERS:
        -----------
        $barcode        = [required] The barcode you want to generate

        $type           = (default=0) It's 0 for Code 3 of 9 (the only one supported)
        
        $width          = (default=160) Width of image in pixels. The image MUST be wide
                                  enough to handle the length of the given value. The default
                                  value will probably be able to display about 6 digits. If you
                                  get an error message, make it wider!

        $height         = (default=80) Height of image in pixels
        
        $format         = (default=jpeg) Can be "jpeg", "png", or "gif"
        
        $quality        = (default=100) For JPEG only: ranges from 0-100

        $text           = (default=1) 0 to disable text below barcode, >=1 to enable

        NOTE: You must have GD-1.8 or higher compiled into PHP
        in order to use PNG and JPEG. GIF images only work with
        GD-1.5 and lower. (http://www.boutell.com)

        ANOTHER NOTE: If you actually intend to print the barcodes 
        and scan them with a scanner, I highly recommend choosing 
        JPEG with a quality of 100. Most browsers can't seem to print 
        a PNG without mangling it beyond recognition. 

        USAGE EXAMPLES FOR ANY PLAIN OLD HTML DOCUMENT:
        -----------------------------------------------

        <IMG SRC="barcode.php?code=HELLO&quality=75">

        <IMG SRC="barcode.php?code=123456&width=320&height=200">
                
        
*/
/*=============================================================================*/

//-----------------------------------------------------------------------------
// Startup code
//-----------------------------------------------------------------------------

if (!isset ($text)) $text = 1;
if (empty ($quality)) $quality = 100;
if (empty ($width)) $width = 160;
if (empty ($height)) $height = 80;
if (!empty ($format)) $format = strtoupper ($format);

switch ($type)
{
        default:
                $type = 1;
        case 1:
                Barcode39 ($barcode, $width, $height, $quality, $format, $text);
                break;          
}

//-----------------------------------------------------------------------------
// Generate a Code 3 of 9 barcode
//-----------------------------------------------------------------------------
function Barcode39 ($barcode, $width, $height, $quality, $format, $text)
{
        switch ($format)
        {
                default:
                        $format = "JPEG";
                case "JPEG": 
                        header ("Content-type: image/jpeg");
                        break;
                case "PNG":
                        header ("Content-type: image/png");
                        break;
                case "GIF":
                        header ("Content-type: image/gif");
                        break;
        }

        $im = ImageCreate ($width, $height)
    or die ("Cannot Initialize new GD image stream");
        $White = ImageColorAllocate ($im, 255, 255, 255);
        $Black = ImageColorAllocate ($im, 0, 0, 0);
        //ImageColorTransparent ($im, $White);
        ImageInterLace ($im, 1);


        $NarrowRatio = 20;
        $WideRatio = 55;
        $QuietRatio = 35;

        $nChars = (strlen($barcode)+2) * ((6 * $NarrowRatio) + (3 * $WideRatio) + ($QuietRatio));
        $Pixels = $width / $nChars;
        $NarrowBar = (int)(20 * $Pixels);
        $WideBar = (int)(55 * $Pixels);
        $QuietBar = (int)(35 * $Pixels);

        $ActualWidth = (($NarrowBar * 6) + ($WideBar*3) + $QuietBar) * (strlen ($barcode)+2);
        
        if (($NarrowBar == 0) || ($NarrowBar == $WideBar) || ($NarrowBar == $QuietBar) || ($WideBar == 0) || ($WideBar == $QuietBar) || ($QuietBar == 0))
        {
                ImageString ($im, 1, 0, 0, "Image is too small!", $Black);
                OutputImage ($im, $format, $quality);
                exit;
        }
        
        $CurrentBarX = (int)(($width - $ActualWidth) / 2);
        $Color = $White;
        $BarcodeFull = "*".strtoupper ($barcode)."*";
        settype ($BarcodeFull, "string");
        
        if ($text != 0)
        {
                $FontNum = 3;
                $FontHeight = ImageFontHeight ($FontNum);
                $FontWidth = ImageFontWidth ($FontNum);
                $CenterLoc = (int)(($width-1) / 2) - (int)(($FontWidth * strlen($BarcodeFull)) / 2);
                ImageString ($im, $FontNum, $CenterLoc, $height-$FontHeight, "$BarcodeFull", $Black);
        }

        for ($i=0; $i<strlen($BarcodeFull); $i++)
        {
                $StripeCode = Code39 ($BarcodeFull[$i]);

                for ($n=0; $n < 9; $n++)
                {
                        if ($Color == $White) $Color = $Black;
                        else $Color = $White;

                        switch ($StripeCode[$n])
                        {
                                case '0':
                                        ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$NarrowBar, $height-1-$FontHeight-2, $Color);
                                        $CurrentBarX += $NarrowBar;
                                        break;

                                case '1':
                                        ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$WideBar, $height-1-$FontHeight-2, $Color);
                                        $CurrentBarX += $WideBar;
                                        break;
                        }
                }

                $Color = $White;
                ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$QuietBar, $height-1-$FontHeight-2, $Color);
                $CurrentBarX += $QuietBar;
        }

        OutputImage ($im, $format, $quality);
}

//-----------------------------------------------------------------------------
// Output an image to the browser
//-----------------------------------------------------------------------------
function OutputImage ($im, $format, $quality)
{
        switch ($format)
        {
                case "JPEG": 
                        ImageJPEG ($im, "", $quality);
                        break;
                case "PNG":
                        ImagePNG ($im);
                        break;
                case "GIF":
                        ImageGIF ($im);
                        break;
        }
}

//-----------------------------------------------------------------------------
// Returns the Code 3 of 9 value for a given ASCII character
//-----------------------------------------------------------------------------
function Code39 ($Asc)
{
        switch ($Asc)
        {
                case ' ':
                        return "011000100";     
                case '$':
                        return "010101000";             
                case '%':
                        return "000101010"; 
                case '*':
                        return "010010100"; // * Start/Stop
                case '+':
                        return "010001010"; 
                case '|':
                        return "010000101"; 
                case '.':
                        return "110000100"; 
                case '/':
                        return "010100010"; 
                case '0':
                        return "000110100"; 
                case '1':
                        return "100100001"; 
                case '2':
                        return "001100001"; 
                case '3':
                        return "101100000"; 
                case '4':
                        return "000110001"; 
                case '5':
                        return "100110000"; 
                case '6':
                        return "001110000"; 
                case '7':
                        return "000100101"; 
                case '8':
                        return "100100100"; 
                case '9':
                        return "001100100"; 
                case 'A':
                        return "100001001"; 
                case 'B':
                        return "001001001"; 
                case 'C':
                        return "101001000";
                case 'D':
                        return "000011001";
                case 'E':
                        return "100011000";
                case 'F':
                        return "001011000";
                case 'G':
                        return "000001101";
                case 'H':
                        return "100001100";
                case 'I':
                        return "001001100";
                case 'J':
                        return "000011100";
                case 'K':
                        return "100000011";
                case 'L':
                        return "001000011";
                case 'M':
                        return "101000010";
                case 'N':
                        return "000010011";
                case 'O':
                        return "100010010";
                case 'P':
                        return "001010010";
                case 'Q':
                        return "000000111";
                case 'R':
                        return "100000110";
                case 'S':
                        return "001000110";
                case 'T':
                        return "000010110";
                case 'U':
                        return "110000001";
                case 'V':
                        return "011000001";
                case 'W':
                        return "111000000";
                case 'X':
                        return "010010001";
                case 'Y':
                        return "110010000";
                case 'Z':
                        return "011010000";
                default:
                        return "011000100"; 
        }
}

?>


yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://patw.idv.tw/blog/archives/119

以下原文轉載

-----------------------------------------------------------------------------

需求是這樣子的:「網站的前台與後台要分別放在不同的域名下,而後台上稿使用 FCKeditor。」

但在插入圖片時,FCKeditor 預設的插入路徑是以 config 檔(端看使用哪種語言開發,如 aspx 的話就是 filemanager/connectors/aspx/config.ascx)中的路徑設置為準。那麼在前台瀏覽時,由於擺放的位置不同,將會找不到正確的圖片路徑。

因此,思考的解法是在插入圖片時,就以圖片的完整URL插入。
此篇剛好有相關的討論與解法。

 

打開 fckeditor 目錄下的 editor\filemanager\browser\default\frmresourceslist.html,
尋找 var sLink = ,共有兩處。將原本的

1
ProtectPath(fileUrl)

改為

1
'http://後台網址/' + fileUrl

修改完畢,FCKeditor 即會以完整網址方式插入圖片了。

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://ecshop.tw/bbs/archiver/tid-2888.html

以下轉載原文

------------------------------------------------------------------------------------------

瀏覽器升級ie9fckedito無法連結圖片等解決方法

升級到 IE 9後,fckeditorIE 9裏的彈出浮動層會出現bug,裏面的內容不會出現。所以無論是想在頁面編輯器裏粘貼內容,還是上傳圖片等凡是需要彈出視窗操作的東西都會有問題,想要進行其他的操作也只能重新刷新頁面。原因是 


升級到 IE 9後,fckeditorIE 9裏的彈出浮動層會出現bug,裏面的內容不會出現。所以無論是想在頁面編輯器裏粘貼內容,還是上傳圖片等凡是需要彈出視窗操作的東西都會有問題,想要進行其他的操作也只能重新刷新頁面。原因是 IE 9 不支持var $=document.getElementById;這樣的寫法了。

解決方法可以這麼來做:
  
打開這個檔, fckeditor/editor/js/fckeditorcode_ie.js ,找到第 38行的這個方法:FCKTools.RegisterDollarFunction
  將原來的

FCKTools.RegisterDollarFunction=function(A){A.$=A.document.getElementById;};
修改方法為:
FCKTools.RegisterDollarFunction=function(A){A.$=function(v){return A.document.getElementById(v);}};
親自做了實驗,結果理想。

yoonow 發表在 痞客邦 留言(2) 人氣()

原文網址:http://is90057.pixnet.net/blog/post/28095884-ckeditor%E8%A8%AD%E5%AE%9A%E6%95%99%E5%AD%B8-(for-php)

以下原文轉載
--------------------------------------------------------------------------

CKEditor 之前的名稱為 FCKEditor,CKEditor是一款 Open Source的所見即所得編輯,透過此編輯器就可輕鬆撰寫文章,並且還可以加粗體變換字體顏色超連結....與圖片上傳等功能,
即便完全不懂任何的HTML語法,也可編輯出一個漂亮的文章頁面出來,並且邊製作還會邊顯示結果,這是個相當方便的功能。

最近因為案子的關系所以使用了CKEditor這個線上編輯的元件,為了怕忘記所以我將設定的方法放上來。

CKeditor(編輯器)/CKfinder(上傳元件)下載:

 

編輯器:CKeditor
支援語法:PHP、ASP、ASP.NET、CF
檔案大小:1.99MB
元件版本:3.5.1
官方展示:
http://ckeditor.com/demo
官方下載:http://ckeditor.com/download


上傳元件:CKfinder
檔案大小:1.01MB
支援語法:PHP、ASP、ASP.NET、CF
元件版本:2.0.1
官方展示:
http://ckfinder.com/demo 
官方下載:
http://ckfinder.com/download

 

下載完畢後,將二個元件放在同一目錄

 

01.JPG 

開啟ckeditor config.js,分別新增以下語法,開始上傳功能。

 

 

config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; //可上傳一般檔案
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';//可上傳圖檔
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';//可上傳Flash檔案

 

後記:

我曾在網路上看到須要在php網頁裏的</body>前加上

 

<?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("editor1");
?>

可是我加上去之後,按上傳圖片完成後,整個網頁都會當掉,後來
我把上述的程式碼拿掉之後,再試之後就不會讓網頁當掉,而且功
能也都正常。

 

 

 

02.JPG 

開啟ckfinder config.php,找到33行將return false改成return true

function CheckAuthentication()
{
 // WARNING : DO NOT simply return "true". By doing so, you are allowing
 // "anyone" to upload and list the files in your server. You must implement
 // some kind of session validation here. Even something very simple as...

 // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

 // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
 // user logs in your system. To be able to use session variables don't
 // forget to add session_start() at the top of this file.

 return true;  <=======原本是return false改成return true
}

03.JPG 

接著到63行處,設定上傳的目錄位置。

$baseUrl = '/網站目錄/存放檔案的目錄/'; //上傳目錄

 


04.JPG 

接下來就新增一個PHP的網頁,在<head></head>中間插入

 

<script type="text/javascriptsrc="ckeditor/ckeditor.js"></script>

新增一個form表單,並放入一個textarea的文字框,並且將name與id設一樣,在texttarea的class屬性設定為ckeditor

<textarea name="textfieldid="textfieldclass="ckeditor"></textarea>

05.JPG 

 

接下來就可以預覽一下網頁,那就大功告成了!

06.JPG 

07.JPG 

後記:

我曾在網路上看到說要在php網頁中的</body>前加上

<?php
include_once "ckeditor/ckeditor.php";
$CKEditor = new CKEditor();
$CKEditor->basePath = 'ckeditor/';
$CKEditor->replace("editor1");
?>

可是加上去的話會按上傳圖片後會讓整個網頁當掉,之後我把上述程式拿掉之後就不會當了,而且功能上也沒啥問題。

 

yoonow 發表在 痞客邦 留言(0) 人氣()

原文網址:http://king971119.blogspot.com/2011/08/javascript-fckeditor-ckeditor.html

以下轉載原文
------------------------------------------------------------------------

如何用 Javascript 取得和設定修改 Fckeditor (CKEditor) 的值

 
假設 CKEditor 欄位名稱叫做 body,那麼當阿舍想用 Javascript 來取得 CKEditor 裡的 HTML 碼時,就可以用下面方式來取得,傳回值會是一個字串: 
1
var ckeditorString = CKEDITOR.instances.body.getData();

相反的,如果要用 Javascript 來塞值到 CKEditor 裡去,那就用 setData() 的方式來做,做法如下: 
1
CKEDITOR.instances.body.setData( '<b>Hello World !</b>' );

取得編輯器中HTML内容 
1
2
3
4
5
6
7
function getEditorHTMLContents(EditorName) {  
 
    var oEditor = FCKeditorAPI.GetInstance(EditorName);  
 
    return(oEditor.GetXHTML(true));  
 
}

取得編輯器中文字内容 
1
2
3
4
5
6
7
function getEditorTextContents(EditorName) {  
 
    var oEditor = FCKeditorAPI.GetInstance(EditorName);  
 
    return(oEditor.EditorDocument.body.innerText);  
 
}

修改編輯器中内容 
1
2
3
4
5
6
7
function SetEditorContents(EditorName, ContentStr) {  
 
    var oEditor = FCKeditorAPI.GetInstance(EditorName) ;  
 
    oEditor.SetHTML(ContentStr) ;  
 
}


//在當前頁面獲得 FCK編輯器 
var Editor = FCKeditorAPI.GetInstance('InstanceName'); 

//从 FCK 編輯器的彈出窗口中獲得FCK編輯器 
var Editor = window.parent.InnerDialogLoaded().FCK; 

//以框架夜面的子框架中取得其他框架中FCK編輯器 
var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName'); 

//以頁面彈出視窗中獲得父窗口FCK編輯器 
var Editor = opener.FCKeditorAPI.GetInstance('InstanceName'); 

//抓取 FCK 編輯器的內容 
oEditor.GetXHTML(formatted); // formatted 为:true|false,表示是否按HTML格式取出 
也可用: 
oEditor.GetXHTML(); 

//設定 FCK 編輯器的內容 
// 第二個參數為:true|false,是否以所得即所得的方式設定內容。此方法通常用在設定初始值或表單重設oEditor.SetHTML("content", false); 

//將內容插入 FCK 編輯器: 
oEditor.InsertHtml("html"); // "html"為HTML文本 

//檢查 FCK 編輯器內容是否有改變 
oEditor.IsDirty();

 

yoonow 發表在 痞客邦 留言(0) 人氣()