/home/web-programming/

Javascripts

Below are useful javascripts that can be easily embedded into your web page. Copy the green text and paste it into your html coding.

PopUp Box – Set window size, window location and window features.

Next: See electronic products at Amazon...

<script type="text/javascript">
function popUp(URL){
winpops=window.open(URL,"","width=500,height=500,left=10,top=10, status=0,scrollbars=1,resizable=1,menubar=1,location=0,toolbar=0")
}
</script>


• Place this within the body to create your link. Change pagename.html to name of your page.

<a href="javascript:popUp('pagename.html')">Place your link text here.</a>


Today's Date


<script type="text/javascript">
today = new Date()
thisMonth = today.getMonth()
thisMonth = (thisMonth * 1) + 1
thisDay = today.getDate()
thisYear = today.getFullYear()
document.write(" ",thisMonth,"/",thisDay,"/",thisYear," ")
</script>



Alert Box

Click to view sample

<script type="text/javascript">
alert('Type your text here!')
</script>



Alert Box with Prompts

Click to view sample

<script type="text/javascript">
var firstName = prompt ("What is your first name?","First Name");
var lastName = prompt ("What is your last name?","Last Name");
var page = document.location
alert('Hi ' + firstName + ' ' + lastName + ', How are you today?')
</script>

Next: See electronic products at Amazon...