หน้าเว็บ

Tech &Tips


เทคนิคการแปะ Code กราฟตลาดทอง

ข้อดีของกราฟตลาดทองคือ เปิดผ่าน IPhone ได้ และโหลดเร็ว  ในส่วนนี้จะเป็นการสอนเทคนิคการนำ Code ไปติดในหน้าเว็บ ในกรณีที่เป็นเว็บมาสเตอร์ ต้องคอยอยู่ที่หน้าเว็บของตัวเองตลอดเวลาก็สามารถดูราคาทองผ่านหน้าเว็บของ ตัวเองได้เลย (ในตัวอย่างนี้จะเป็นการติดCodeกราฟตลาดทองผ่านเว็บสำเร็จรูป)
<iframe border="0" frameborder="0" height="158" marginheight="0" marginwidth="0" scrolling="no" src="http://taradthong.com/webadmin/embed-vertical2.php" width="178"></iframe>


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


               วิธีเก็บทราฟฟิคจาก Error 404 - File Not Found






          หลาย ๆ คนที่เล่นอินเตอร์เน็ต คงจะเคยคลิกลิงค์ที่สนใจ ซึ่งอาจจะมาจากเว็บไซต์บางเว็บไซต์ หรือ จากเว็บบอร์ดบางแห่ง เพื่อต้องการดูข้อมูลเพิ่มเติมตามลิงค์ที่เค้าแป๊ะำไว้ แต่บางครั้ง คงจะเคยเจอกันมาบ้าง ที่เมื่อคลิกลิงค์ เข้าไปแล้วแทนที่จะเจอเว็บไซต์ หน้าข้อมูลที่เราต้องการ หน้าบราวเซอร์กลับขึ้นหน้าขาว ๆ พร้อมขึ้นขอความ File Not Found กรณีเข้าเว็บไซต์ผ่าน Firefox หรือ The page cannot be found กรณีเข้าเว็บไซต์ผ่าน IE ขึ้นมาแทน และคิดว่าสิ่งที่ทุก ๆ คนจะทำหลังจากนั้นก็คือ ปิดหน้าบราวเซอร์หน้านั้น แล้วไปหาข้อมูลที่สนใจจากที่อื่น ๆ ต่อไป









สำหรับสาเหตุของการเกิด Error 404 - File Not Found หรือ - Error 404 - The page cannot be found นั้นก็เกิดมาจากการหาไฟล์หรือข้อมูลที่มีการเรียกผ่านบราวเซอร์ แต่กลับไม่มีข้อมูลนี้ใน Server ซึ่งก็คือหาไฟล์ที่มีการร้องขอไม่เจอ ซึ่งอาจเกิดมาจากสาเหตุ เช่น การระบุลิงค์ URL ที่จะเข้าถึงไม่ถูกต้อง ซึ่งอาจจะเพราะพิมพ์ URL แล้วมี blank (ช่องว่าง) หรืออาจจะหาไฟล์ไม่พบ เพราะไฟล์มีการสูญหายไปจาก Server ซึ่งอาจเกิดขึ้นได้จากการที่ Server ล่ม แล้วมีการกู้ไฟล์มาได้ไม่ครบถ้วน เป็นต้น







และในฐานะที่เราเป็นเว็บมาสเตอร์ เป็นคนดูแลเว็บไซต์ แล้วมีการเกิด Error 404 กับเว็บไซต์เราเป็นจำนวนมาก นั่นหมายถึงมีคนสนใจจะเข้ามาชมเว็บไซต์ของเรา แต่กลับไม่สามารถเข้าเว็บมาได้ ซึ่งกลายเป็นว่าเราได้สูญเสียทราฟฟิคไปจำนวนไม่น้อย คำถามคือจะดีแค่ไหน ถ้าเราสามารถเก็บทราฟฟิคจาก Error 404 หรือทำให้การเกิด Error 404 แล้วเว็บไซต์ของเราไม่เสียประโยชน์ ... คำตอบคือต้องดีแน่ ๆ ละค่ะ และวันนี้ Webmaster เลยเอาเทคนิคเล็ก ๆ น้อย ๆ ที่หามาได้ ลองใช้แล้ว Work มาแบ่งปันเพื่อน ๆ คนทำเว็บไซต์






เริ่มต้นที่การสร้างไฟล์ .htaccess โดยเปิดโปรแกรม Notepad แล้วทำการเขียนคำสั่งตามที่ปรากฏในภาพที่ 3 จากนั้นให้เซฟไฟล์ โดยชื่อไฟล์เป็น .htaccess 
ขั้นตอนต่อมาก็สร้างไฟล์อีกไฟล์ โดยเปิดโปรแกรม Notepad แล้วพิมพ์คำสั่ง php ตามภาพที่ 4 (เปลี่ยน URL ตรง mywebsite เป็นเว็บไซต์ของเรา) จากนั้นให้เซฟไฟล์ โดยตั้งชื่อไฟล์เป็น error404.php






จากนั้นเมื่อสร้างไฟล์ทั้ง 2 ไฟล์แล้ว ก็ให้อัพโหลดไฟล์ทั้ง 2 ไปไว้ที่ Root Server ของเรา (ที่เดียวกับไฟล์ index)


สำหรับการทำงานของไฟล์คำสั่งที่เราเขียนไปนั้น เมื่อเวลามีการติดต่อ Server จะมีการตรวจเช็คไฟล์ .htaccess ซึ่งเป็นไฟล์ config สั่งงานเบื้องต้นของ Apache Server โดยในไฟล์ .htaccess เราเขียนไว้แปลความหมายภาษามนุษย์คือ เมื่อเกิด Error 404 ขึ้นใน Server ให้ Server ทำการเรียกไปยังไฟล์ ที่มีชื่อว่า error404.php ซึ่งในไฟล์ ๆ นี้ เราก็ได้เขียนคำสั่งให้มีการไปเปิดหน้าแรกของเว็บไซต์ของเรา


สรุปก็คือ ทุกครั้งที่มีการเกิด Error 404 ขึ้น บราวเซอร์ก็จะไปเปิดหน้าแรกของเว็บไซต์เรามาแสดงแทนนั่นเอง ทำให้เว็บไซต์ของเรายังได้ทราฟฟิคเข้าเว็บไซต์ ถึงแม้จะมีการเกิด Error 404 ก็ตาม

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


แสดง IP สำหรับผู้เข้าชมเว็บ

นำ Code ด้านล่างไปติดระหว่าง <head>.............</head>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
// http://www.kdcgrohl.com

// Depending on your server set-up,
// you may need to use the ".shtml"
// extension // or "htm"> as the script uses Server
// Side Includes. To display in the
// title bar, exclude the
//"<title></title>" code from the page.

// This part gets the IP
var ip = '<!--#echo var="REMOTE_ADDR"-->';

// This part is for an alert box
alert("Your IP address is "+ip);

// This part is for the status bar
window.defaultStatus = "Your IP address is "+ip;

// This part is for the title bar
document.write("<title>Your IP address is "+ip+"</title>");
// End -->
</script> 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Mouse มีนาฬิกาตามหลังด้วย


เอา Code ไปแปะกันได้เลยไม่ยากไม่เย็น

นำไว้ระหว่าง Head


<!-- Free JavaScripts at http://www.ScriptBreaker.com -->

<SCRIPT language=JavaScript>

fCol='546546';//face colour.
sCol='000000';//seconds colour.
mCol='000000';//minutes colour.
hCol='000000';//hours colour.
ClockHeight=40;
ClockWidth=40;
ClockFromMouseY=0;
ClockFromMouseX=50;

date=new Date();
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900;
H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
Face='1 2 3 4 5 6 7 8 9 10 11 12';
font='Arial';
size=1;
speed=0.6;
ns=(document.layers);
ie=(document.all);
Face=Face.split(' ');
n=Face.length;
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";
Split=360/n;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=-7;
HandX=-2.5;
scrll=0;
step=0.06;
currStep=0;
y=new Array();x=new Array();Y=new Array();X=new Array();
for (i=0; i < n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}
if (ns){
for (i=0; i < n; i++)
document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face[i]+'</font></center></layer>');
for (i=0; i < S.length; i++)
document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>');
for (i=0; i < M.length; i++)
document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>');
for (i=0; i < H.length; i++)
document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>');
}
if (ie){
document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < n; i++)
document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props+Face[i]+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++)
document.write('<div id="ieHours" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+'</div>');
document.write('</div></div>');
document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++)
document.write('<div id="ieMinutes" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+'</div>');
document.write('</div></div>')
document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++)
document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+'</div>');
document.write('</div></div>')
}
(ns)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY;
xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;
}
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function ClockAndAssign(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;
if (ie){
Of.style.top=window.document.body.scrollTop;
Oh.style.top=window.document.body.scrollTop;
Om.style.top=window.document.body.scrollTop;
Os.style.top=window.document.body.scrollTop;
}
for (i=0; i < n; i++){
 var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style;
 F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;
 F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);
 }
for (i=0; i < H.length; i++){
 var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style;
 HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;
 HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs);
 }
for (i=0; i < M.length; i++){
 var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;
 ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;
 ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);
 }
for (i=0; i < S.length; i++){
 var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style;
 SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;
 SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec);
 }
currStep-=step;
}
function Delay(){
scrll=(ns)?window.pageYOffset:0;
y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
for (i=1; i < n; i++){
y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);
x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);
}
ClockAndAssign();
setTimeout('Delay()',20);
}
if (ns||ie)window.onload=Delay;
</SCRIPT>


<!-- end Source -->

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>