總網頁瀏覽量

2016年11月20日 星期日

[HTML] 加入 JavaScript

兩種方式:
1. 在 html 中利用 <script> 標籤將 JavaScript 程式碼包含入內.
2. 用 src 屬性引入 ".js" 檔案.

第一種:

<script language="JavaScript>
    JavaScript code
</script>

language 屬性:
告知瀏覽器目前使用哪種 Script 語言,以書中提及的語言有兩種 JavaScript 和 VBScript,
其實也可以直接利用 <script> .. </script> 將程式碼包住就好,
但是就要確定瀏覽器一定將預設的 Script 設定為 JavaScript.

有舊版的瀏覽器無法支援 JavaScript,
避免這些無法支援的瀏覽器在使用 JavaScript 時會直接把 JavaScript 程式碼印,
就可以利用 HTML 的註解 ( <!--    -->) 和 JavaScript 的註解 (//) 混合使用.

<script language="JavaScript">
<!--

//-->
<noscript>
瀏覽器不支援 JavaScript
</noscript>

 noscript 標籤讓不支援 JavaScript 的瀏覽器執行或顯示標籤內的文字或效果.


使用 src 屬性:

在 IE4.X 和 Netscape 3.X開始, 才可以適用此種方法載入外部 JavaScript 檔案(*.js)

<script=" [Data Name].js>


</script>


Exception:

<HTML>
    <head>
        <meta http-equiv = "Content-Type" content="text/html; charset=big">
        <title> Test connent </title>
        <script language ="JavaScript" src = "welcome.js">
        </script>
    </head>
    <body>
        <a href= "doc8.html">echo</a>
        <script language="JavaScript">
        <!--
            document.write("First JavaScript Exception");
        //-->
        </script>
        <noscript>
            瀏覽器不支援 JavaScript
        </noscript>
    </body>
</HTML>

利用  document.write() 將要在 JavaScript 顯示的語言用此包覆.

JavaScript  放置位置:

可以放在 <head> </head> 和 <body> </body> 標籤內,
在 <head> </head> 內放入程式碼,可以讓 JavaScript 在進入頁面時以視窗顯示.
在 <body> </body> 內放入程式碼,則是在一般網路頁面顯示.


參考來源:HTML & JavaScript 實用寶典

2016年11月16日 星期三

[C/C++] warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

程式發生這個 Warning
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

問題在於某個要呼叫的函式

ClassName::Function("AAAA: \n%s", str.c_str());

到 ClassName class 的 Function 的位置看這個函式

static void ClassName(char *format,...);

那修改就是加個 const

static void ClassName(const char *format,...);

靜態的字串不能變動, 再函式呼叫要加 const


Linux 環境下所使用的GCC或是編譯程式版本在目前最新的情況下會出現,

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

為什麼呢?原來char *背後的含義是:給我個字符串,我要修改它。

而理論上,我們傳給函數的字面常量是沒法被修改的。

所以說,比較和理的辦法是把參數類型修改為const char *。

很自然的延伸一下。

如果我既要傳字面常量又要傳字符串變量怎麼辦呢?......重載

說明的參考網站: https://read01.com/K88LP.html 從這裡看到上面這段的
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

2016年11月15日 星期二

[] Virtualbox 的 USB 無法正確連接 (無法解決)

查了很多資料但是沒辦法一下解決,
也不知道問題在哪,
所以在這裡先來記錄一下測試結果給自己看.

指示以附加USB的活動性: 未附加USB裝置

一開始查一定會先查到說, 因為 Oracle VirtualBox 的版本更新到了 5.1.8,
就會需要安裝擴充程式  VirtualBox 5.1.8 Oracle VM VirtualBox Extension Pack,
在按下下載鍵  All supported platforms
結果以為USB功能回來了

原來一切都是假的, 業障太重,
那就只好繼續往下追查了.

那 Extension Pack 是什麼呢,
原來是 VirtualBox  把USB和遠端功能拆開了,
從內建功能變擴充元件,
目的應該是為了增加它的延展性吧,
但是害死我了.
資料來源: http://www.arthurtoday.com/2011/01/oracle-vm-virtualbox-40-extension-pack.html


查網路有很多種大同小異的執行順序,
但是其實就是一個 vboxusers 問題. 目前所知 <-

目前都用 終端機上進行測試, 英文應該是 T... , 太長 我用 cmd.

先查看目前使用者位於哪個群組中

cmd -> group  也有看到 group [username] 結果一樣

: [username] adm .......

沒有看到 vboxusers 就代表 [usermame] 沒有在 vboxusers  中

所以就匯要求把使用者加入該群組中

cmd -> sudo usermod -a -G vboxusers  [username]

: usermod: group 'vboxusers' does not exist

沒錯 並不是所有的 ubuntu 都有 'vboxusers'

cmd -> grep xboxusers /etc/group

沒回應, 代表真的 xboxusers 根本不再電腦群組中

沒有的話就自己新增

cmd -> groupadd xboxusers
 : groupadd: Permission denied.
 : groupadd: cannot lock /etc/group; try again later.

結果又說什麼類似權限上的錯誤

改權限

cmd -> chmod +x  xboxusers

: chmod: 無法存取 'xboxusers': 沒有此一檔案或目錄.

可能是改目錄權限才對

cmd -> chmod +x /etc/group

: chmod: 正在更改 '/etc/group' 的權限: 此項操作並不被允許

啃雞腿 又不行 換個方法

cmd -> sudo qpasswd -a o012 vboxusers

: gpassed: group 'vboxusers' does not exist in /etc/group


慘 都不能

之後看到了在舊版的 ubuntu 中所謂的群組管理,
但是到新版就不見了,
所以現在重新裝回來,

cmd -> sudo apt-get install gnome-system-tools

按 系統設定值 -> 使用者帳號

啃雞腿 沒變阿 應該要在我的帳號下面多一行 [群組管理] button阿

現在我用 搜尋您的電腦和現在來源 直接打關鍵字 user

就跑出 [使用者與群組]

點下去就會看到舊版的 [使用者設定值] 視窗

底下就會多了一個 button [管理群組(M)]

在下面的群組中找 vboxusers,

沒錯 我的一定沒有

那我就按加入 把 vboxusers 加進去

再重新打開我的 Virtualbox ubuntu

...............................................................................................................

還是不行 到底哪裡有問題

最後放棄,
先裝舊版的 VMBox把USB參數設定好,
在安裝 ExtensionPack,
再把VMBox的版本升級到目前最新的,
然後就解決了.


雖然解決之前的問題還是不知道為啥...








2016年11月7日 星期一

[C/C++] std String clear()

C++98
void clear();

Clear string
Erases the contents of the string, which becomes an empty string (with a length of 0 characters).
清除字串的內容值, 使之成為空字串.

感覺上干涉到 cout 的一些執行方式, 需要再去查看.


// string::clear
#include <iostream>
#include <string>

int main ()
{
  char c;
  std::string str;
  std::cout << "Please type some lines of text. Enter a dot (.) to finish:\n";
  do {
    c = std::cin.get();
    str += c;
    if (c=='\n')
    {
       std::cout << str;
       str.clear();
    }
  } while (c!='.');
  return 0;
}

This program repeats every line introduced by the user until a line contains a dot ('.'). Every newline character ('\n') triggers the repetition of the line and the clearing of the current string content.

程式輸入使用者內容值, 只要碰到 '\n' 則輸出到螢幕上顯示,
再用 clear() 清空字串.

Please type some lines of text. Enter a dot (.) to finish:
a < input
a < output
b < input
b < output
cc dd
cc dd

.

離開時使用 '.' 作為離開字元.
如果將 str.clear(); 註解.
變回得到以下輸出:

Please type some lines of text. Enter a dot (.) to finish:
a < input
a < output
b < input
a < output
b < output
cc dd < input
a < output
b < output
cc dd < output

.

可以看到前次的輸入將會在下一的輸出中顯示.


參考網址: http://www.cplusplus.com/reference/string/string/clear/

2016年10月9日 星期日

[HTML] 學習 006 CSS 怎麼加

先前已經有個簡單的加入CSS的範例了,
那將 CSS 與網頁結合,
主要就會透過 CSS 選取器來對 HTML 標籤進行控制.

選取器有三種:
1. 標籤選取器
2. Class 選取器
3. ID 選取器
利用先前範例來進行修改看看改變狀態.

原先網頁:

<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Conntent</title>
</head>
<body bgcolor="99FF99" text="#FFFFFF">
<table width ="608" hright="320" border="1">
    <tr>
        <td align= "center" bgcolor="blue">Blue</td>
        <td align= "center" bgcolor="green">Green</td>
        <td align= "center" bgcolor="red">Red</td>
    </tr>
    <p>
        ABCDEFG
    </p>
</table>
<a href ="http://www.google.com.tw/" target="_black">Botton to connent the network </a>
</body>
</html>



1. 標籤選取器 - 將,<p> 和 </p> 內的字體做調整.



<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Conntent</title>
<style>
    p{
        font-family: Arial;
        color:#F00;
    }
</style>

</head>
<body bgcolor="99FF99" text="#FFFFFF">
<table width ="608" hright="320" border="1">
    <tr>
        <td align= "center" bgcolor="blue">Blue</td>
        <td align= "center" bgcolor="green">Green</td>
        <td align= "center" bgcolor="red">Red</td>
    </tr>
    <p>
        ABCDEFG
    </p>
</table>
<a href ="http://www.google.com.tw/" target="_black">Botton to connent the network </a>
</body>
</html>



由粗體部分來看,
利用大括號 { } 將所有屬性與值包起來,
表示一個完整的 CSS 宣告.

其中屬性與值用 : 來區隔, 屬性與屬性用 ; 來區隔.

在 CSS 宣告結束後,
網頁內的所有對應標籤內容就會套用宣告的樣式效果.

 


2. Class 選取器


3. ID 選取器





From 精通 CSS 網頁設計法則


2016年10月8日 星期六

[HTML] 學習 005 CSS 的一些知識

from 精通CSS 網頁設計法則

CSS 的其一個優點是能在任意瀏覽器呈現風格效果,
而能這樣被廣泛應用的原因是因為應用了 W3C 的準則.

W3C world wide consortium

一個網頁三個部分組成
1. Structure
2. Presentation
3. Behavior

Structure
網頁內的元素安排, 如圖片, 標題和內文.
語言如XHTML1.0, XHTML1.1 和 XML1.0.

Presentation
網頁呈現方式, 文字, 背影和色調.
語言如CSS1, CSS2 和 CSS3.

Behavior
網頁內容互動, 如提交資料, 選單顯示等.
語言如ECMAScript 262, D3C DOM.

在W3C中提供了一個判斷用戶的 CSS 是否合於規範的網站,
http://jigsaw.w3.org/css-validator/validator.html.en


2016年10月4日 星期二

[HTML] 學習 004 css 與 HTML 轉變顯示語法









先由程式碼來看,
HTML 的程式碼:
doc3.html
<html>
   <head>
   <meta charset="UTF-8">
   <title>Sample document</title>
   <link rel= "stylesheet" href="style1.css">
   </head>
  
   <body>
        <h3><font color="#000099" face ="微軟整正黑體"> 標籤1 </font></h3>
        <p>正文1</p>
        <h3><font color="#000099" face ="微軟整正黑體"> 標籤2 </font></h3>
        <p>正文2</p>  
        正文3      
   </body>
</html>

再來看使用了 css 的程式碼
doc4.html
<html>
   <head>
   <meta charset="UTF-8">
   <title>Sample document</title>
    <style>
        h3{
            font-family:"微軟整正黑體";
            color:#000099;
        }
    </style>

    <link rel= "stylesheet" href="style1.css">
   </head>
  
   <body>
        <h3> 標籤1 </h3>
        <p>正文1</p>
        <h3> 標籤2 </h3>
        <p>正文2</p>  
        正文3      
   </body>
</html>

利用 css 來將該網頁的 <h3>  標籤所框選的內容直接修改,
在程式碼的情況下程式將變得更加的清晰明瞭.

下圖示以上兩個程式碼執行顯示後的樣子.