Personalized Greeting
From DHTML Wiki
Always follow this structure when posting new code:
Insert a discription of what your script/code does.
Contents |
[edit] User Information
Invented by Matthewinventor 22:03, 28 March 2008 (UTC) of Greetings Lightbulb Productions. Tested in Internet Explorer.
[edit] Code
<button onclick="greetUser()" id="experience" onmouseover="document.getElementById('experience').innerHTML = 'With Interactivity'" onmouseout="document.getElementById('experience').innerHTML = 'Experience the Web'">Experience the Web</button><marquee id="name" style="border-width: medium" behavior="alternate" scrolldelay="100" onmouseover="credit()">Hello. </marquee>
<script type="text/javascript">var userName;
function greetUser() {
userName = window.prompt("What is your name?", "John Doe");
document.getElementById("name").innerHTML = "Hello, " + userName + ".";
}
function credit() {
if (userName) {
document.getElementById("name").innerHTML = "Hello, " + userName + ". Get this code to put this on YOUR site at lightbulbproductions.net/funstuff/jstoys.htm#Personalized Greetings";
} else {
document.getElementById("name").innerHTML = "Hello. Get the code to put this on YOUR website at lightbulbproductions.net/funstuff/jstoys.htm#Personalized Greetings";
}
} </script>
[edit] How To Use
Example: Upload the image from this page and this JavaScript file into the same folder as the page you are using this script in and paste the HTML code into it.
[edit] Edits
- Examples:
- Matthewinventor 23:16, 14 March 2008 (UTC) Debugged syntax error on line 7
- Matthewinventor 23:16, 14 March 2008 (UTC) Added <!-- --> comment to line 72
