InvisionFree - Free Forum Hosting
Create a free forum in seconds.

Learn More · Register for Free
Welcome to V2p. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Name:   Password:


 

 JaVa hay
beckham_in_china
Posted: May 5 2004, 03:32 PM


Administrator


Group: Admin
Posts: 708
Member No.: 1
Joined: 29-April 04



CODE
<html><!-- #BeginTemplate "/Templates/tpl_jscript.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->

<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- #BeginEditable "extra" -->
<script language="Javascript">
//--------------------------------------------------
// Splash an object's background color
// Copyrighted 2003 by Bao Tran - www.hoaibao.net
//--------------------------------------------------

var spObj, spId, spSpeed = 25, spColor = ["#FFFFFF", "#666666", ""];

function Splash(Obj) {
spObj = Obj;
spColor[2] = spObj.style.backgroundColor;
Splashy(0);
}
function StopSplash() {
clearTimeout(spId);
spObj.style.backgroundColor = spColor[2];
}
function Splashy(i) {
spObj.style.backgroundColor = spColor[i++];
spId = setTimeout("Splashy(" + (i == 3 ? 0 : i) + ");", spSpeed);
}
</script>
<!-- #EndEditable -->
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #BeginEditable "cont" -->
<div id="Obj0" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 200px; top:200px; border:1px solid #000000; background-color:#0099FF"></div>
<div id="Obj1" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 240px; top:200px; border:1px solid #000000; background-color:#999999"></div>
<div id="Obj2" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 280px; top:200px; border:1px solid #000000; background-color:#FFCC00"></div>
<div id="Obj3" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 320px; top:200px; border:1px solid #000000; background-color:#009900"></div>
<div id="Obj4" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 360px; top:200px; border:1px solid #000000; background-color:#FF6699"></div>
<div id="Obj5" onMouseOver="Splash(this);" onMouseOut="StopSplash();" style="position:absolute; width:40px; height:20px; left: 400px; top:200px; border:1px solid #000000; background-color:#00CCFF"></div>

<!-- You don't need this line below -->
<div style="position:absolute; top:20px; left:80%; width:100px; text-align:center; font-family:verdana,arial; font-size:10pt; cursor:hand; border:1px solid #0099FF" onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'" onClick="location.href='view-source:'+location.href">Source
 code</div>
<!-- #EndEditable -->
</body>
<!-- #EndTemplate --></html>
Top
beckham_in_china
Posted: May 5 2004, 03:33 PM


Administrator


Group: Admin
Posts: 708
Member No.: 1
Joined: 29-April 04



Tuyết rơi ! Script ¨¢p dụng h¨¤m sin của To¨¢n. Rất đơn giản
CODE
<html><!-- #BeginTemplate "/Templates/tpl_jscript.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->

<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- #BeginEditable "extra" -->
<script language="Javascript">
//-----------------------------------------------
// Made by Bao Tran - 2002 - www.hoaibao.net
// Script: Snow
//-----------------------------------------------

var MaxFlake = 25;
var MaxH, MaxW, Flakes = new Array();
var d = document;

if(d.getElementById) sRef = function(id) { return d.getElementById(id).style; };
else if(d.all) sRef = function(id) { return d.all[id].style; };
else { alert("Old browser, snow can't fall :-)"); }

function Positioning() {
MaxW = (d.body.clientWidth || window.innerWidth || d.documentElement.clientWidth || 750) - 30;
MaxH = (d.body.clientHeight || window.innerHeight || d.documentElement.clientHeight || 400) - 5;
}
function MakeFlakes() {
for(var i = 0; i < MaxFlake; i++) {
 Flakes[i] = { S:sRef('f'+i), P:(i+1)*(MaxW/MaxFlake) };
 Flakes[i].S.left = Flakes[i].P + "px";
 Flakes[i].S.top = Math.round(Math.random() * MaxH) + "px";
}
}
function LoopFalling() {
for(var i = 0; i < MaxFlake; i++) {
 if(parseInt(Flakes[i].S.top) >= MaxH)
  Flakes[i].S.top = 0 + "px";
 Flakes[i].S.top = (parseInt(Flakes[i].S.top) + 1) + "px";
 Flakes[i].S.left = (20 * Math.sin(50 * parseInt(Flakes[i].S.top)) + Flakes[i].P) + "px";
}
setTimeout("LoopFalling();", 100);
}
function Resize() {
Positioning();
MakeFlakes();
}
function StartSnowing() {
Positioning();
for(var i = 0; i < MaxFlake; i++)
 document.write("<div id='f" + i + "' style='position:absolute; height:2px; width:2px; background-color:#FFFFFF; z-index:100'><div></div></div>");
MakeFlakes();
LoopFalling();
window.onresize = Resize;
}
</script>
<style>
body {background-color:#0099FF}
</style>
<!-- #EndEditable -->
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #BeginEditable "cont" -->
<!-- You don't need this line below --->
<!-- If empty page, "keep" the line below, Opera 6.05 doesn't like empty page;-) -->
<p>&nbsp;

<script language="Javascript">
// Should be placed after at least one HTML element (Opera 6.05 fix)
StartSnowing();
</script>

<!-- You don't need this line below -->
<div style="position:absolute; top:20px; left:80%; width:100px; text-align:center; font-family:verdana,arial; font-size:10pt; cursor:hand; border:1px solid #0099FF" onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'" onClick="location.href='view-source:'+location.href">Source
 code</div>
<!-- #EndEditable -->
</body>
<!-- #EndTemplate --></html>
Top
beckham_in_china
Posted: May 5 2004, 03:33 PM


Administrator


Group: Admin
Posts: 708
Member No.: 1
Joined: 29-April 04



Menu ngang, 2 level. Bao nhiêu item cũng được. Script này ḿnh viết lúc mới bắt đầu tham khảo javascript nên không hay cho lắm
CODE
<html><!-- #BeginTemplate "/Templates/tpl_jscript.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->

<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- #BeginEditable "extra" -->
<style>
.hmenu {border: 1px #FFFFFF solid; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #0099FF; cursor: hand; text-align: left; background-color: #FFFFFF}
</style>
<script language="Javascript">
var HMenu = new Array();
var Top, Left, Div;
var CurrentSub;
var IsMouseOnCurrentSub = 0;
var IntervalId;
var newWd;
var WdId = 0;
var TopOffset = 0;
var LeftOffset = 0;
var SubMinWidth;

function AddMain (Main, URL, Target) {
HMenu[HMenu.length] = new Array();
HMenu[HMenu.length-1][0] = Main;
HMenu[HMenu.length-1][1] = URL;
HMenu[HMenu.length-1][2] = Target;  
HMenu[HMenu.length-1][3] = new Array();
}
function AddSub1 (Sub, URL, Target) {
var Item = new Array();
Item[0] = Sub;
Item[1] = URL;
Item[2] = Target;
HMenu[HMenu.length-1][3][HMenu[HMenu.length-1][3].length] = Item;
}
function ShowSub(it) {
for (var i = 0; i < HMenu.length; i++) {
 document.getElementById("Menu"+i+"Sub").style.visibility = "hidden";
 document.getElementById("Menu"+i).style.backgroundColor = '#FFFFFF';
 document.getElementById("Menu"+i).style.borderColor = '#FFFFFF';
}
document.getElementById(it).style.visibility = "visible";
document.getElementById(it.substr(0,5)).style.backgroundColor = "#EEEEEE";
document.getElementById(it.substr(0,5)).style.borderColor = "#666666";
}
function HideSub(it) {
document.getElementById(it).style.visibility = "hidden";
document.getElementById(it.substr(0,5)).style.backgroundColor = '#FFFFFF';
document.getElementById(it.substr(0,5)).style.borderColor = '#FFFFFF';
}
function Check() { if (IsMouseOnCurrentSub == 0) { HideSub(CurrentSub); } }
function GoTo(theLink, theTarget) {
if (theLink != '#') {
 if (theTarget == "_blank") {
  newWd = window.open(theLink, "Wd" + (WdId++));
  newWd.focus();
 } else {
  location.href = theLink;
 }
}
}
function m_move(it,bgColor,bdColor,txtColor) {
if (it.style) {
 it.style.backgroundColor = bgColor;
 it.style.borderColor = bdColor;
 it.style.color = txtColor;
}
}
function MakeMenu() {
var Table = "<table id=\"HM\" align='left' cellspacing='1' cellpadding='2' style=\"border:1px #CCCCCC solid; background-color:#FFFFFF\"><tr>";
for (var i = 0; i < HMenu.length; i++) {
 Table += "<td id=\"Menu" + i + "\" class='hmenu' onMouseOver=\"ShowSub(this.id+'Sub');m_move(this,'#EEEEEE','#666666','');CurrentSub = this.id+'Sub';clearInterval(IntervalId);\" onMouseOut=\"clearInterval(IntervalId);IntervalId = setInterval(Check, 500);\" onClick=\"GoTo('" + HMenu[i][1] + "', '" + HMenu[i][2] + "');\">" + HMenu[i][0] + "</td>";
 if (i != HMenu.length-1) {Table += "<td width='2'></td>";}
}
Table += "</tr></table>";
HMCont.innerHTML = Table;

for (i = 0; i < HMenu.length; i++) {
 Top = HMCont.offsetTop + HMCont.clientHeight + TopOffset;
 Left = HMCont.offsetLeft + HM.offsetLeft + document.getElementById("Menu"+i).offsetLeft + LeftOffset;
 Div = "<div id=\"Menu" + i + "Sub\" style=\"position:absolute; top:" + Top + "px; left:" + Left + "px; z-index:1; " + ((HMenu[i][3].length != 0) ? "border:1px solid #666666; background-color:#FFFFFF; " : '') + "visibility:hidden\" onMouseOver=\"ShowSub(this.id);IsMouseOnCurrentSub = 1;\" onMouseOut=\"IsMouseOnCurrentSub = 0;\">";
 Div += "<table id=\"Sub" + i + "\" cellspacing='0' cellpadding='2' align='left'>";
 for (var k = 0; k < HMenu[i][3].length; k++) {
  if (HMenu[i][3][k][0].length > 13) {
   SubMinWidth = '';
   break;
  } else { SubMinWidth = "width='100' ";}
 }
 for (var j = 0; j < HMenu[i][3].length; j++) {
  Div += "<tr><td class='hmenu' " + SubMinWidth;
  Div += "onMouseOver=\"m_move(this,'#EEEEEE','','')\" onMouseOut=\"m_move(this,'#FFFFFF','','')\" onClick=\"GoTo('" + HMenu[i][3][j][1] + "', '" + HMenu[i][3][j][2] + "');\">" + HMenu[i][3][j][0] + "</td></tr>";
 }
 Div += "</table></div>";
 document.write(Div);
}
}
</script>
<!-- #EndEditable -->
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #BeginEditable "cont" -->
<!-- You don't need this line below --->
<!-- Modify the top and left postion in style below ------->
<div id="HMCont" style="position:absolute; left:189px; top:87px; width:176px; height:20px; z-index:1"></div>

<script language="Javascript">
//------------------------------------------------------------
//Copyright Bao Tran 2002 -- www.hoaibao.net
//Script:   HMenu
//Example: AddMain("Menu1", "Menu1.html", "_blank");
//     AddSub1("Sub1", "Sub1.html", "_self");
//     AddSub1("Sub2", "#", "_blank");
//
//Note: - Target can only be _blank or _self, no frames.
//      - Put a # in the URL if you don't want the link to go anywhere
//------------------------------------------------------------

<!-- Add your menu below (sample shown) -->

AddMain("About","#","_self");
 AddSub1("About me", "aboutme.html", "_self");
 AddSub1("About site", "aboutsite.html", "_blank");

AddMain("Links","#","_self");
 AddSub1("hoaibao.net", "http://www.hoaibao.net", "_self");
 AddSub1("codeB", "http://userwww.sfsu.edu/~codeb", "_self");
 AddSub1("Hotmail", "http://www.hotmail.com", "_blank");
 AddSub1("Yahoo", "http://www.yahoo.com", "_self");
 AddSub1("MSN", "http://www.msn.com", "_blank");

AddMain("Projects","#","_self");
 AddSub1("VietTyper", "#", "_blank");
 AddSub1("MusicStreamer", "#", "_blank");

AddMain("Home","#","_self");
<!-- End ---->

MakeMenu(); // make the menu, very important
</script>

<!-- You don't need this line below -->
<div style="position:absolute; top:20px; left:80%; width:100px; text-align:center; font-family:verdana,arial; font-size:10pt; cursor:hand; border:1px solid #0099FF" onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'" onClick="location.href='view-source:'+location.href">Source
 code</div>
<!-- #EndEditable -->
</body>
<!-- #EndTemplate --></html>
Top
beckham_in_china
Posted: May 5 2004, 03:34 PM


Administrator


Group: Admin
Posts: 708
Member No.: 1
Joined: 29-April 04



Di chuyển 1 vật nào đó (div) theo ư của bạn
CODE
<html><!-- #BeginTemplate "/Templates/tpl_jscript.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->

<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- #BeginEditable "extra" -->
<script language="Javascript">
//--------------------------------------------------
// JS Library
// Copyrighted 2002 by Bao Tran - www.hoaibao.net
//--------------------------------------------------

function Deref(Id) { return document.getElementById(Id).style; } //dereference an object's style

// Id: the object's ID
// From: move from where
// To: move to where
// Sp: how fast you want the object to move

function MoveLeft(Id, From, To, Sp) {
if(From < To) { Deref(Id).left = To + "px"; }  // finish moving
else {
 Deref(Id).left = From + "px";
 setTimeout("MoveLeft('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
}
}
function MoveRight(Id, From, To, Sp) {
if(From > To) { Deref(Id).left = To + "px"; }  // finish moving
else {
 Deref(Id).left = From + "px";
 setTimeout("MoveRight('" + Id + "'," + (From + Sp) + "," + To + "," + Sp + ");", 20);
}
}
function MoveUp(Id, From, To, Sp) {
if(From < To) { Deref(Id).top = To + "px"; }  // finish moving
else {
 Deref(Id).top = From + "px";
 setTimeout("MoveUp('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
}
}
function MoveDown(Id, From, To, Sp) {
if(From > To) { Deref(Id).top = To + "px"; }  // finish moving
else {
 Deref(Id).top = From + "px";
 setTimeout("MoveDown('" + Id + "'," + (From + Sp) + "," + To + "," + Sp + ");", 20);
}
}
</script>

<!-- #EndEditable -->
</head>

<body bgcolor="#FFFFFF" text="#000000">
<!-- #BeginEditable "cont" -->
<!-- You don't need this line below --->
<div id="Obj" style="position:absolute; width:20px; height:20px; left: 400px; top:200px; border:1px solid #000000; background-color:#0099FF"></div>
<p>Di chuyển 100 px, tốc độ: 5<br>
<input type="submit" name="Submit" value="Trái" onClick="MoveLeft('Obj',Deref('Obj').pixelLeft, Deref('Obj').pixelLeft-100, 5);">
<input type="submit" name="Submit" value="Phải" onClick="MoveRight('Obj',Deref('Obj').pixelLeft, Deref('Obj').pixelLeft+100, 5);">
<input type="submit" name="Submit" value="Lên" onClick="MoveUp('Obj',Deref('Obj').pixelTop, Deref('Obj').pixelTop-100, 5);">
<input type="submit" name="Submit" value="Xuống" onClick="MoveDown('Obj',Deref('Obj').pixelTop, Deref('Obj').pixelTop+100, 5);">

<!-- You don't need this line below -->
<div style="position:absolute; top:20px; left:80%; width:100px; text-align:center; font-family:verdana,arial; font-size:10pt; cursor:hand; border:1px solid #0099FF" onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'" onClick="location.href='view-source:'+location.href">Source
 code</div>
<!-- #EndEditable -->
</body>
<!-- #EndTemplate --></html>
Top
beckham_in_china
Posted: May 5 2004, 03:35 PM


Administrator


Group: Admin
Posts: 708
Member No.: 1
Joined: 29-April 04



Giăn nở hoặc thu nhỏ 1 object (div)
<html>
CODE
<!-- #BeginTemplate "/Templates/tpl_jscript.dwt" -->
<head>
<!-- #BeginEditable "doctitle" -->

<!-- #EndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- #BeginEditable "extra" -->
<script language="Javascript">
//--------------------------------------------------
// JS Library
// Copyrighted 2002 by Bao Tran - www.hoaibao.net
//--------------------------------------------------

function Deref(Id) { return document.getElementById(Id).style; } //dereference an object's style

// Id: the object's ID
// From: from where
// To: to where
// Sp: how fast you want the object to stretch or collapse

function SpanRight(Id, From, To, Sp) {
if (From > To) { Deref(Id).width = To + "px"; }  // finish stretching right
else {
 Deref(Id).width = From + "px";
 setTimeout("SpanRight('" + Id + "'," + (From + Sp) + "," + To + "," + Sp + ");", 20);
}
}
function SpanDown(Id, From, To, Sp) {
if (From > To) { Deref(Id).height = To + "px"; }  // finish stretching down
else {
 Deref(Id).height = From + "px";
 setTimeout("SpanDown('" + Id + "'," + (From + Sp) + "," + To + "," + Sp + ");", 20);
}
}
function PullLeft(Id, From, To, Sp) {
if(To > 0) {
 if (From < To) { Deref(Id).width = To + "px"; }  // finish pulling left
 else {
  Deref(Id).width = From + "px";
  setTimeout("PullLeft('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
 }
}
}
function PullUp(Id, From, To, Sp) {
if(To > 0) {
 if (From < To) { Deref(Id).height = To + "px"; }  // finish pulling up
 else {
  Deref(Id).height = From + "px";
  setTimeout("PullUp('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
 }
}
}
function MoveLeft(Id, From, To, Sp) {
if(From < To) { Deref(Id).left = To + "px"; }  // finish moving
else {
 Deref(Id).left = From + "px";
 setTimeout("MoveLeft('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
}
}
function MoveUp(Id, From, To, Sp) {
if(From < To) { Deref(Id).top = To + "px"; }  // finish moving
else {
 Deref(Id).top = From + "px";
 setTimeout("MoveUp('" + Id + "'," + (From - Sp) + "," + To + "," + Sp + ");", 20);
}
}
</script>
<!-- #EndEditable -->
</head>
<body bgcolor="#FFFFFF" text="#000000">
<!-- #BeginEditable "cont" -->
<div id="Obj" style="position:absolute; width:20px; height:20px; left: 400px; top:200px; border:1px solid #000000; background-color:#0099FF"></div>
<p>Vật giăn nở 100 px, tốc độ: 5<br>
<input type="submit" name="Submit" value="Trái" onClick="MoveLeft('Obj', Deref('Obj').pixelLeft, Deref('Obj').pixelLeft-100, 5);SpanRight('Obj', Deref('Obj').pixelWidth, Deref('Obj').pixelWidth+100, 5);">
<input type="submit" name="Submit" value="Phải" onClick="SpanRight('Obj', Deref('Obj').pixelWidth, Deref('Obj').pixelWidth+100, 5);">
<input type="submit" name="Submit" value="Lên" onClick="MoveUp('Obj', Deref('Obj').pixelTop, Deref('Obj').pixelTop-100, 5);SpanDown('Obj', Deref('Obj').pixelHeight, Deref('Obj').pixelHeight+100, 5);">
<input type="submit" name="Submit" value="Xuống" onClick="SpanDown('Obj', Deref('Obj').pixelHeight, Deref('Obj').pixelHeight+100, 5);">

<br><p>Vật thu lại 100 px, tốc độ: 5<br>
<input type="submit" name="Submit" value="Trái" onClick="PullLeft('Obj', Deref('Obj').pixelWidth, Deref('Obj').pixelWidth-100, 5);">
<input type="submit" name="Submit" value="Lên" onClick="PullUp('Obj', Deref('Obj').pixelHeight, Deref('Obj').pixelHeight-100, 5);">

<!-- You don't need this line below -->
<div style="position:absolute; top:20px; left:80%; width:100px; text-align:center; font-family:verdana,arial; font-size:10pt; cursor:hand; border:1px solid #0099FF" onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor='#FFFFFF'" onClick="location.href='view-source:'+location.href">Source
 code</div>
<!-- #EndEditable -->
</body>
<!-- #EndTemplate -->
</html>
Top
« Next Oldest | Thiết Kế Web | Next Newest »
InvisionFree - Free Forum Hosting
Join the millions that use us for their forum communities. Create your own forum today.
Learn More · Register for Free

Topic Options



Hosted for free by InvisionFree* (Terms of Use: Updated 2/10/2010) | Powered by Invision Power Board v1.3 Final © 2003 IPS, Inc.
Page creation time: 0.2536 seconds | Archive