| CARVIEW |
Archive for the ‘JavaScript’ Category
You can use JavaScript code to redirect user to a page you want. For instance, when a user tries points his/her address bar to https://mywebsite.com, you can have that page automatically redirected to https://www.mywebsite.com using only one line of JavaScript code!
All you need to do is to paste the following code in the <head> section of your html page:
<script language=”JavaScript”>
window.location=”https://www.mypage.com”
</script>
This function can also be used to redirect users to appropriate versions of web pages depending on which browser they are using. It’s a very simple and handy script, easy to remember and easy to use. Do comment on any other ways of redirecting a user to another page that you may know of!
– Millie
Rate this:
JS Tip 4: How to change background colors with JavaScript
Posted by: Millie Patel on: November 24, 2009
You can use JavaScript commands with the onClick parameter in the input tags of an html form. Wow! That sounds like a complicated line eh? Lol…so it very easy to have the background color of a page changed on the click of a button. Just read the script below – it’s fairly easy to understand:
<FORM>
<INPUT value="Change to Yellow!" onClick="document.bgColor='yellow'">
<INPUT value="Change to Red!" name="button4"> <br>
<INPUT value="Change back!" name="button5">
</FORM>
When you include this code snippet in your html page, it will display 3 buttons; one to change the background color of the page to yellow, one to red and the third to change it back to the original one we started with, i.e. white. The only piece of JavaScript you need to remember here is the document.bgColor and once you assign it with a value, you have a ready script that works!
Obviously you don’t have to use JavaScript to change the background color of a page, you could specify the color you want in the <body> tag of your html script like this:
<body bgcolor="red">
The purpose of this tutorial was just to demonstrate the use of the JavaScript function document.bgColor.
I hope this tip was helpful. You can leave a comment if you want me to set my feet on other aspects of this wonderful scripting language! I’ll definitely write a post about it and illustrate its use.
– Millie
Rate this:
JS Tip 3: How to display the date and time using JavaScript
Posted by: Millie Patel on: November 8, 2009
- In: JavaScript
- 1 Comment
This is a very simple one. JavaScript has inbuilt functions that you just include in your code. See the snippet below:
<html> <title>Time & Date Display</title> <head> <script language = "JavaScript"> var today = new Date() document.write(today); </script> </head> <body> Displaying Time Using JavaScript </body> </html>
That’s just about it. You declare a variable called today and assign it the Date() function. Then use document.write to display it on your webpage.
– Millie
Rate this:
JS Tip 2: How to collect data from forms
Posted by: Millie Patel on: October 27, 2009
On my previous post about how to display alert messages, you’ll see that the messages are specified in quotes within the script. What if you wanted to display user-generated data on the alerts which pop up? How would you do that? You have to first display a form through which you will collect some information. Then in your JavaScript function, you have to call the values you get from the form so that it picks up and displays what the user enters. Here’s a simple example:
<html> <title>Displaying user data in the alert messages</title> <head> <script language = "JavaScript"> function displayalert() { alert('Welcome ' + document.FORM1.yourname.value + '! Your Age is ' + document.FORM1.yourage.value) } </script> </head>
<body> Please Enter Your Name & Age in the textboxes Below, Then Click on 'Submit'...<p> <form name = "FORM1"> Your Name: <input type="Text" Name="yourname"><p> Your Age: <input Name="yourage"><p> <input type="button" value="Submit" onClick="displayalert()"><p> <input type="reset" value="Refresh"> </form> </body> </html>
The form [FORM1] collects the user’s name and age, and the JavaScript function displayalert() uses the document.FORM1.yourname.value to pick that value, which will be displayed in the alert. Notice that the JavaScript function to display the alert is being called from the Submit onClick property.
I hope this tutorial has been explained well, do leave comments on your opinions or if you think I should change something. Happy Programming!
– Millie
Rate this:
- In: JavaScript
- 3 Comments
Often you’ll see messages popping up to alert you about something or to give you extra information on something. These can be programmed using JavaScript and it’s very simple. See the code below – It’s easy to understand.
<html>
<head>
<title>Displaying Alerts with JavaScript</title>
<script language = "JavaScript">
<!--
function m_alert()
{
alert('Do not Click..!!!');
alert('I Told You Not To Click Me..!!');
alert('Why Did You Click???!!!');
alert('You Will Never See Me Again!!!');
}
-->
</script>
</head>
<body>
<a href="#" onMouseover = "m_alert()"> Dont Click This Link </a>
</body>
</html>
Simply copy the code above, paste it into a notepad file and save the file with a .html extension, e.g. alerts.html.
The link has a mouseover function which calls the JavaScript funtion when you hover it. When writing JavaScript code, always remember to end the lines of code with a semicolon (;). Try and see how it works! You can use alerts in your websites to pass on certain messages easily.
– Millie
Rate this:
Search
Blog Stats
- 45,566 hits
Blogroll
- Another cool blog Nice techie posts!
- Best Software The Best Software to download
- Ganesh Sketches! Wonderful sketches of Ganesh, made by Rajan
- hkay’s blog
- Humor Addict! A funny blog that will make your day!
- Joboholic!! The latest on the Jobs Front!!
- Making it big online! Cool blog that helps you to make money!
- Making Money Online Guide to ‘How To Make Money Online’
- My Online Portfolio You can see the projects I work on here!
- My Tech Store!! Buy lots of good stuff from here!!
- SEO Link Building A cool SEO blogs with lots of tips!
- Seriously Funny Videos!
- The Techies Techie Blog
- WordPress.com
- WordPress.com Blog
- WordPress.org
Go Around The Tech Corner…
- Google Play, Interestingly Time Consuming!
- Tech Tip 72: Save Money on SIM-only Deals
- Tech Tip 71: Learn WordPress the Easy Way!
- Success with Micro Jobbing Sites
- Suggesters.org helps you select the right laptop
- IT Support Services: On the Run!
- Responsive Design for Websites
- Tech Tip 70: Ubiquitous File Access
- Tech Tip 69: The Easiest Way of Handling Payroll
- Tech Tip 68: Customize your Mobile in a Stylish Way
Categories
- JavaScript (5)
- Miscellaneous Posts (34)
- PhotoShop (4)
- Tech News (22)
- Tips & Tricks (76)
- Uncategorized (1)
Archives
- October 2012
- September 2012
- May 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- May 2011
- April 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- June 2009
- May 2009
- April 2009
- February 2009
- December 2008
- November 2008
- September 2008
Top Posts
- Google Play, Interestingly Time Consuming!
- Tech Tip 72: Save Money on SIM-only Deals
- Tech Tip 71: Learn WordPress the Easy Way!
- Success with Micro Jobbing Sites
- Suggesters.org helps you select the right laptop
- IT Support Services: On the Run!
- Responsive Design for Websites
- Tech Tip 70: Ubiquitous File Access
- Tech Tip 69: The Easiest Way of Handling Payroll
- Tech Tip 68: Customize your Mobile in a Stylish Way
Top Clicks
- None
Flickr Photos
TechExperience
-
Subscribe
Subscribed
Already have a WordPress.com account? Log in now.







Recent Comments