[r]
(1)Code tạo hình trái tim tên bạn
<html><body>
<script type="text/javascript">
function createHeart(sourceId, resultId) {
objSource = window.document.getElementById(sourceId); objResult = window.document.getElementById(resultId); if(objSource.value.length == 0) {
alert("Bạn chưa nhập đoạn text cần tạo hình trái tim vào trống!"); return false;
}
string = objSource.value; heart = "";
heart += " _" + partString(string, 8) + " " + partString(string, 9) + "\n"; heart += " " + partString(string, 12) + " _" + partString(string, 15) + "\n";
heart += " " + partString(string, 17) + " _" + partString(string, 18) + "\n"; heart += " _" + partString(string, 41) + "\n";
heart += " " + partString(string, 44) + "\n"; heart += "_" + partString(string, 46) + "\n"; heart += "_" + partString(string, 46) + "\n"; heart += partString(string, 47) + "\n"; heart += partString(string, 47) + "\n"; heart += partString(string, 46) + "\n"; heart += partString(string, 45) + "\n"; heart += "_" + partString(string, 43) + "\n"; heart += " " + partString(string, 41) + "\n"; heart += " " + partString(string, 38) + "\n"; heart += " " + partString(string, 34) + "\n"; heart += " _" + partString(string, 28) + "\n"; heart += " " + partString(string, 22) + "\n"; heart += " " + partString(string, 18) + "\n"; heart += " _" + partString(string, 13) + "\n"; heart += " _" + partString(string, 9) + "\n"; heart += " _" + partString(string, 6) + "\n"; heart += " " + partString(string, 4) + "\n"; heart += " _" + partString(string, 2) + "\n"; objResult.value = heart;
}
function partString(string, num) { if(string.length >= num)
(2)repeat = Math.ceil(num / string.length); newString = "";
for(i = 0; i < repeat; i++) newString += string;
return newString.substring(0, num); }
</script>
<p align="center">nhập từ mún tạo thành trái tim vào đây<br /><input id="text" name="text" size="37"></p><p align="center"><input name="Create Heart" accesskey="g" onclick="return createHeart('text', 'result');" value="Tạo trái tim" type="button"></p><p align="center">Copy hình vừa tạo dán vào blog thôi.</p><p align="center"><textarea cols="45" rows="23"
readonly="readonly" wrap="OFF" id="result" onclick="this.focus(); this.select();"></textarea><p align="center">Thích khơng ^^</p><p align="center"><strong>© <a