/    Sign up×
Community /Pin to ProfileBookmark

window popup javascript

i am looking for a java script that like a window popup but i want the visitor to be able to type in their name and have it show up in the webpage.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@MikeFosterSep 03.2004 — Here's an easy way to do that...
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;title&gt;User Name&lt;/title&gt;
&lt;script type='text/javascript'&gt;
window.onload = function()
{
setupUserName();
}
function setupUserName()
{
if (document.getElementById) {
var user = prompt('Please enter your name:', '');
if (!user) {
user = 'NoName';
alert("Ok, so I'll call you NoName.");
}
var ele = document.getElementById('userName');
if (ele &amp;&amp; ele.innerHTML) {
ele.innerHTML = 'Welcome ' + user + '!';
}
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h1 id='userName'&gt;Welcome!&lt;/h1&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@mackss1authorSep 03.2004 — hey thanks

that was what i was looking for all along.
Copy linkTweet thisAlerts:
@mackss1authorSep 03.2004 — how do i change the font?

i need it to garmond 12pt and the text white.
Copy linkTweet thisAlerts:
@MikeFosterSep 03.2004 — <i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;title&gt;User Name&lt;/title&gt;
&lt;style type='text/css'&gt;
body {
font-family: Garamond,Georgia,Serif;
font-size: 12pt;
color: #FFF;
background: #CC9;
}
&lt;/style&gt;
&lt;script type='text/javascript'&gt;
window.onload = function()
{
setupUserName();
}
function setupUserName()
{
if (document.getElementById) {
var user = prompt('Please enter your name:', '');
if (!user) {
user = 'NoName';
alert("Ok, so I'll call you NoName.");
}
var ele = document.getElementById('userName');
if (ele &amp;&amp; ele.innerHTML) {
ele.innerHTML = 'Welcome ' + user + '!';
}
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h1 id='userName'&gt;Welcome!&lt;/h1&gt;

&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @mackss1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...