XML - 資料交換管理/XUL/答案
外觀
< XML - 資料交換管理 | XUL
(從 XML - 資料交換管理/XUL (答案) 重定向)練習
- 建立一個包含兩個文字框的視窗,文字框距離視窗底部大約 200 畫素。使用垂直或水平佈局。為每個文字框新增標籤並設定預設值,這些值彼此不同。建立一個標有“交換文字”的按鈕。接下來,建立一個函式,當單擊該按鈕時,將交換兩個文字框中的文字。
- 在本練習中,您需要建立兩個獨立的檔案。在一個頁面上,建立一個包含兩個帶標籤的面板的視窗,每個面板的內容不同。在另一個頁面上,只需建立一個包含一個名為“開啟”的選單項的彈出選單。建立一個函式,當單擊“開啟”選單選項時,將瀏覽器重定向到帶標籤的頁面。
問題 1:答案
XulNum1.js
function swap()
{
var noDanaObj=document.getElementById('nodana');
var onlyXulObj=document.getElementById('onlyxul');
var noDanaStr=noDanaObj.getAttribute("value");
var onlyXulStr=onlyXulObj.getAttribute("value");
noDanaObj.setAttribute("value",onlyXulStr);
onlyXulObj.setAttribute("value",noDanaStr);
}
|
XulNum1.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
id="Ex1"
title="Excercise 1"
orient="vertical"
xmlns= "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="XulNum1.js" />
<hbox width="200px" height="200px" flex = "1">
<text value= "There is no Dana..." id="nodana" style="font-size:18pt"/>
</hbox>
<hbox width="200px" height="200px" flex = "1">
<text value="There is only XUL" id="onlyxul" style="font-size:24pt"/>
</hbox>
<box width="200px">
<button id="swap" label="swap" default="true" oncommand="swap();"/>
</box>
</window>
|