第一組:楊昊 有關(guān)表格的樣式設(shè)定問(wèn)題——固定頭、列
前幾天接到的任務(wù)中,有這樣一個(gè)需求:就是表單的頭部、首列需要固定,不要隨著滾動(dòng)條的變化而移動(dòng),如下:
去網(wǎng)上查了一下,這種操作主要是css方面的,方法有很多,但是都逃不過(guò)兩個(gè)屬性:
position: relative;
z-index:99;
position屬性:規(guī)定元素的定位類型,relative是指生成相對(duì)定位的元素,相對(duì)于其正常位置進(jìn)行定位。比如"left:20" 會(huì)向元素的 left 位置添加 20 像素。
z-index屬性:設(shè)置元素的堆疊順序。擁有更高堆疊順序的元素總是會(huì)處于堆疊順序較低的元素的前面。其中,元素可擁有負(fù)的 z-index 屬性值。z-index 僅能在定位元素上奏效。
我在實(shí)現(xiàn)這個(gè)操作時(shí)使用的是jQuery的方式,將樣式動(dòng)態(tài)注入。代碼如下:
附代碼:
首列固定
$(".table-p").scroll(function () {
if ($(".table-p").scrollTop() > 0) {
var Htable_flinew2 = $(".table-p").scrollTop() + "px";
$(".tdwid2").css("position", "relative");
$(".tdwid2").css("background", "#fff");
$(".tdwid2").css("top", Htable_flinew2);
} else {
$(".tdwid2").css("top", "0");
}
if ($(".table-p").scrollLeft() > 0) {
var Htable_flinew = $(".table-p").scrollLeft() + "px";
$(".table tbody tr td:first-child").css("left", Htable_flinew);
$(".table thead tr th:first-child").css("left", Htable_flinew);
} else {
$(".table tbody tr td:first-child").css("left", "0");
$(".table thead tr th:first-child").css("left", "0");
}
})
第二組:馮佳麗 使用ng-repeat指令來(lái)循環(huán)圖片數(shù)組并且加入img模板、AuguarJS服務(wù)和依賴注入、 scopes
1. 使用ng-repeat指令來(lái)循環(huán)圖片數(shù)組并且加入img模板
function AlbumCtrl($scope) {
scope.images = [
{"image":"img/image_01.png", "description":"Image 01 description"},
{"image":"img/image_02.png", "description":"Image 02 description"},
{"image":"img/image_03.png", "description":"Image 03 description"},
{"image":"img/image_04.png", "description":"Image 04 description"},
{"image":"img/image_05.png", "description":"Image 05 description"}
];
}
<div ng-controller="AlbumCtrl">
<ul>
<li ng-repeat="image in images">
<img ng-src="http://m.cnblogs.com/142260/{{image.thumbnail}}" rel="nofollow"/>
</li>
</ul>
</div>
2. AuguarJS服務(wù)和依賴注入
function EditCtrl($scope, $location, $routeParams) {
// Something clever here...
}
定義自己的服務(wù)并且讓它們注入:
angular.module('MyServiceModule', []).
factory('notify', ['$window', function (win) {
return function (msg) {
win.alert(msg);
};
}]);
function myController(scope, notifyService) {
scope.callNotify = function (msg) {
notifyService(msg);
};
}
myController.$inject = ['$scope', 'notify'];
3. scopes
$scope是一個(gè)把view(一個(gè)DOM元素)連結(jié)到controller上的對(duì)象。在我們的MVC結(jié)構(gòu)里,這個(gè) $scope 將成為model,它提供一個(gè)綁定到DOM元素(以及其子元素)上的excecution context。
$scope 實(shí)際上就是一個(gè)JavaScript對(duì)象,controller和view都可以訪問(wèn)它,所以我們可以利用它在兩者間傳遞信息。在這個(gè) $scope 對(duì)象里,我們既存儲(chǔ)數(shù)據(jù),又存儲(chǔ)將要運(yùn)行在view上的函數(shù)。
每一個(gè)Angular應(yīng)用都會(huì)有一個(gè) $rootScope。這個(gè) $rootScope 是最頂級(jí)的scope,它對(duì)應(yīng)著含有ng-app 指令屬性的那個(gè)DOM元素。
app.run(function($rootScope) { $rootScope.name = "張三"; });
如果頁(yè)面上沒(méi)有明確設(shè)定 $scope ,Angular 就會(huì)把數(shù)據(jù)和函數(shù)都綁定到這里。
這樣,我們就可以在view的任何地方訪問(wèn)這個(gè)name屬性,使用模版表達(dá)式{{}},像這樣:{{ name }} 。
第三組:黃華英 String 方法和頁(yè)面調(diào)用
1. String 方法
String 方法 | 含義 |
---|---|
string.charAt(i) | 返回在 string 中 i 位置處的字符。 |
string.charCodeAt(i) | 返回在 string 中 i 位置處的字符編碼。比如字符串“hello world!”charCodeAt(1) 為101 |
str.indexOf(aaa, start) | 在 str 中查找另一個(gè)字符串 aaa返回第一個(gè)被匹配字符的位置,否則返回-1,start表示查找的起始位置 |
str.lastIndexOf(aaa, start) | 與 indexOf 方法類似,但它是從該字符串的末尾開始查找 |
strA.localeCompare(strB) | 比較兩個(gè)字符串。如果 strA比strB小,結(jié)果為負(fù)數(shù),若相等結(jié)果為0 |
string.match(regexp) | 它匹配一個(gè)字符串或者一個(gè)正則表達(dá)式,該方法類似 indexOf() 和 lastIndexOf(),但是它返回指定的值,而不是字符串的位置 |
比如
str=”123456”
匹配字符串str.match(“12”)得到12
匹配正則表達(dá)式str.match(/\d+/g)得到123456
str.replace(searchstr, replacestr)對(duì) string 進(jìn)行查找和替換操作,并返回一個(gè)新的字符串
string.split(select, limit),split 方法把這個(gè) string 分隔成片段來(lái)創(chuàng)建一個(gè)字符串?dāng)?shù)組
例如
var Strarray =“123456789”
Strarray.split(‘’,4)得到{1},{2},{3},{456789}四個(gè)數(shù)組
string.ToLower(),把 string 中的所有字母轉(zhuǎn)換為小寫格式
string.ToUpper(),把 string 中的所有字母轉(zhuǎn)換為大寫格式
string.fromCharCode(char...),從一串?dāng)?shù)字中返回一個(gè)字符串
2. 頁(yè)面調(diào)用
- 后臺(tái)調(diào)用父頁(yè)面方法并且關(guān)閉當(dāng)前頁(yè)面
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('操作成功!');
parent.ParentFunction ();parent.CloseAlertPage();", true);
- 前臺(tái)子頁(yè)面調(diào)用父頁(yè)面方法
parent.Parent Function();
- 父頁(yè)面調(diào)用子頁(yè)面(iframe)的js方法
window.frames["iframe子頁(yè)面的name"].方法名();
第四組:張?jiān)? __main__.py
文件與 python -m
PYTHON 的 -M 參數(shù)用于將一個(gè)模塊或者包作為一個(gè)腳本運(yùn)行,而__MAIN__.PY
文件則相當(dāng)于是一個(gè)包的”入口程序“。
首先我們需要來(lái)看看 PYTHON XXX.PY 與 PYTHON -M XXX.PY 的區(qū)別。兩種運(yùn)行 PYTHON 程序的方式的不同點(diǎn)在于,一種是直接運(yùn)行,一種是當(dāng)做模塊來(lái)運(yùn)行。
先來(lái)看一個(gè)簡(jiǎn)單的例子,假設(shè)有一個(gè) PYTHON 文件 RUN.PY,其內(nèi)容如下:
IMPORT SYS
PRINT SYS.PATH
我們用直接運(yùn)行的方式啟動(dòng)(PYTHON RUN.PY),輸出結(jié)果:
['/HOME/HUOTY/ABOUTME/PYTHONSTUDY/MAIN', ...]
然后以模塊的方式運(yùn)行(PYTHON -M RUN.PY):
['', ...]
/USR/BIN/PYTHON: NO MODULE NAMED RUN.PY
由于輸出結(jié)果只列出了關(guān)鍵的部分,應(yīng)該很容易看出他們之間的差異。直接運(yùn)行是把 RUN.PY 文件所在的目錄放到了 SYS.PATH 屬性中。以模塊方式運(yùn)行是把你輸入命令的目錄(也就是當(dāng)前工作路徑),放到了 SYS.PATH 屬性中。以模塊方式運(yùn)行還有一個(gè)不同的地方是,多出了一行 NO MODULE NAMED RUN.PY 的錯(cuò)誤。實(shí)際上以模塊方式運(yùn)行時(shí),PYTHON 先對(duì) RUN.PY 執(zhí)行一遍 IMPORT,所以 PRINT SYS.PATH 被成功執(zhí)行,然后 PYTHON 才嘗試運(yùn)行 RUN.PY 模塊,但是,在 PATH 變量中并沒(méi)有 RUN.PY 這個(gè)模塊,所以報(bào)錯(cuò)。而正確的運(yùn)行方式,應(yīng)該是 PYTHON -M RUN.
這個(gè)例子并不能明顯的說(shuō)明問(wèn)題。接著我們來(lái)看看__MAIN__.PY
的作用。
仍然先看例子,有如下一個(gè)包:
package
├── __init__.py
└── __main__.py
__init__.py
import sys
print "__init__"
print sys.path
__main__.py
import sys
print "__main__"
print sys.path
用 PYTHON -M PACKAGE 運(yùn)行結(jié)果:
__init__
['', ...]
__main__
['', ...]
用 PYTHON PACKAGE 運(yùn)行結(jié)果:
__main__
['package', ...]
- 加上 -m 參數(shù)時(shí)會(huì)把當(dāng)前工作目錄添加到 sys.path 中,而不加時(shí)則會(huì)把腳本所在目錄添加到 sys.path 中。
- 加上 -m 參數(shù)時(shí) Python 會(huì)先將模塊或者包導(dǎo)入,然后再執(zhí)行
-
__main__.py
文件是一個(gè)包或者目錄的入口程序。不管是用 python package 還是用python -m package 運(yùn)行時(shí),__main__.py
文件總是被執(zhí)行。
第五組:姜葳 JS刷新頁(yè)面
1. 刷新當(dāng)前頁(yè)面
<script>
window.location.reload();
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
2. JS實(shí)現(xiàn)刷新iframe的方法
<input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">
或
< input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">
3. 子頁(yè)面刷新父頁(yè)面
(1)parent.location.href = parent.location.reload();
(2)<script language=JavaScript>
self.opener.location.reload();
</script>
(或<a href="javascript:opener.location.reload()">刷新</a> )
4.開窗時(shí)刷新和關(guān)閉時(shí)刷新
<body onload="opener.location.reload()"> 開窗時(shí)刷新
<body onUnload="opener.location.reload()"> 關(guān)閉時(shí)刷新
5. AlertPage彈出的窗口,關(guān)閉時(shí)刷新
代碼:
function InvoiceDetail() {
AlertPage("AmInvoiceDetails.aspx?isNeedVerify=no&Type=verify”, "發(fā)票詳情", 900, 800);
OpeningDialog.openingDialog.bind("close", function () {
location.reload();
})
}
流水落花春去也,天上人間