| |||||||
This is a discussion on Some sweet useful JavaScripts within the HTML/CSS/JavaScript section, part of the Programming category; Change Table Colour On MouseOver A neat little trick for changing the colour of a table row on mouseover. Paste ...
![]() |
|
| | LinkBack (1) | Thread Tools | Display Modes |
#1
| ||||
| ||||
| Change Table Colour On MouseOver A neat little trick for changing the colour of a table row on mouseover. Paste the code into the body of your page. You may edit the table data as necessary. HTML Code: <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr bgcolor="#e8e8e8" onMouseOver="this.bgColor = '#FFBC58'" onMouseOut="this.bgColor = '#e8e8e8'"> <td>Tech6</td> <td>S60 Games/Apps</td> <td>OS 7,8,9 ...</td> <td><a href="http://tech6.com/forumdisplay.php?f=21" target="_top" onFocus="if(this.blur)this.blur()">more...</a></td> </tr> <tr bgcolor="#e8e8e8" onMouseOver="this.bgColor = '#FFBC58'" onMouseOut="this.bgColor = '#e8e8e8'"> <td>Tech6</td> <td>Programming Res.</td> <td>HTML/CSS/JS, C/C++/VC++, ASP/ASP.NET, ...</td> <td><a href="http://tech6.com/forumdisplay.php?f=13" target="_top" onFocus="if(this.blur)this.blur()">more...</a></td> </tr> </table>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#2
| ||||
| ||||
| Moves the cursor on to the next form field automatically once the current one has been completed. Useful when entering dates. HTML Code: Paste this in the HEAD section.... <script language="JavaScript"> //AutoTab function var field_length=0; function TabNext(obj,event,len,next_field) { if (event == "down") { field_length=obj.value.length; } else if (event == "up") { if (obj.value.length != field_length) { field_length=obj.value.length; if (field_length == len) { next_field.focus(); } } } } </SCRIPT> ######## Paste this in the BODY section <form name="form1" method="post" action=""> <input type="text" name="Day" size="2" maxlength="2" onKeyDown="TabNext(this,'down',2)" onKeyUp="TabNext(this,'up',2,this.form.Month)"> <input type="text" name="Month" size="2" maxlength="2" onKeyDown="TabNext(this,'down',2)" onKeyUp="TabNext(this,'up',2,this.form.Year)"> <input type="text" name="Year" size="4" maxlength="4"> <input type="submit" name="Submit" value="Submit"> </form>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#3
| ||||
| ||||
| This script turns radio buttons into links.. You can now also click on the text beside the radio button to opt. HTML Code: <script language=JavaScript> function select(radio, value) { var elementnr = radio * 4 + value; document.forms[0].elements[elementnr].checked = true; } </script> <form name="Answers" action="theanswers.asp" method=post> <input type="radio" value="1" name="answer[0]"><a href="javascript:select(0,0);">No</a><br> <input type="radio" value="2" name="answer[0]"><a href="javascript:select(0,1);">Yes</a><br> <input type="radio" value="3" name="answer[0]"><A href="javascript:select(0,2);">Maybe</a> </form>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#4
| ||||
| ||||
| A simple but nice date/time script. Code: <script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new
Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+","+year+"")
</script>
<span id=tick2>
</span>
<script>
<!--
function show2(){
if (!document.all&&!document.getElementById)
return
thelement=document.getElementById? document.getElementById("tick2"):
document.all.tick2
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="PM"
if (hours<12)
dn="AM"
if (hours>12)
hours=hours-12
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
var ctime=hours+":"+minutes+":"+seconds+" "+dn
thelement.innerHTML=""+ctime+""
setTimeout("show2()",1000)
}
window.onload=show2
//-->
</script>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#5
| ||||
| ||||
| Description: Quick and easy way to countdown the days to a specific date. In this example the 11,25 sets the date to the 25th of December (JavaScript counts months from zero (0) so 0=January through to 11 = December. Instructions: SETTING THE DATE-- The 11,25 sets the date to the 25th of December (JavaScript counts months from zero (0) so 0=January through to 11 = December Code: <!--Paste this bit in the HEAD section of your HTML page-->
<SCRIPT language=JAVASCRIPT>
<!--
now = new Date
countdown = new Date (now.getFullYear(),11,25)
if (countdown.getTime() < now.getTime()) {
countdown.setYear(countdown.getFullYear()+1)
}
function dayToDays(inTime) {
return (Math.floor(inTime.getTime() / (1000 * 60 * 60 * 24)))
}
function daysTill(inDate) {
return dayToDays(inDate) - dayToDays(now)
}
-->
</SCRIPT>
<!------------- --------------->
<!--Paste this bit in the BODY section of your HTML page-->
<script language=JAVASCRIPT>
<!--
document.write(daysTill(countdown))
-->
</script>
DAYS TO CHRISTMAS
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#6
| ||||
| ||||
| Uses a Button to close a window HTML Code: <input type="button" value="Close" onclick="javascript:self.close();"> HTML Code: <input type="button" value="Go" onclick="parent.location='http://tech6.com'"> HTML Code: <input type="button" value="Go" onclick="window.open('http://tech6.com')"> HTML Code: <input type="button" value="Go Next" onClick="javascript:history.go(1)"> HTML Code: <input type="button" value="Go Back" onClick="javascript:history.go(-1)"> HTML Code: <input type="button" value="Send me an email" onclick="parent.location='mailto:youremail@email.com'"> HTML Code: <input type="button" value="Print" onclick="javascript:window.print()"> HTML Code: <input type="button" value="Make This Site Your Home Page" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://tech6.com');"> HTML Code: <input type="button" value="Add to Favorites" onClick='window.external.AddFavorite(location.href, document.title);'> HTML Code: <input type="button" value="View Source" onClick= 'window.location = "view-source:" + window.location.href' > Note:- Some of the above snippets would work just for IE.
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#7
| ||||
| ||||
| If you've ever discovered that someone has linked to your web site within a frame, which means your site is stuck in their frame with their information displaying within another frame, you know how frustrating this can be. You want your visitors to visit your web site within their standard browser window - not within another web site's frame. The following JavaScript code will enable you to prevent your web site from being framed. Add the following onLoad attribute to your <body> tag: HTML Code: <body onLoad="if (self != top) top.location = self.location">
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#8
| ||||
| ||||
|
Thanks, I am using all of them in my new website.
__________________ My iPhone is better than yours........... I Am Back! |
|
#9
| ||||
| ||||
|
Thank you so much. Please keep posting |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://tech6.com/f14/some-sweet-useful-javascripts-t86/ | ||||
| Posted By | For | Type | Date | |
| Background Hover color - vBulletin.org Forum | This thread | Refback | 25-07-2009 08:46 PM | |