More Help!!!!

Code:
<SCRIPT>
function getname(){
//this is the name of the function
var thiscookie=document.cookie;
//this retrieves the cookie
var location=thiscookie.indexOf("surfername=");
//this is the location of where the information starts
var endlocation=thiscookie.indexOf(":");
//this is the location of the end of the information
if (location != -1){
//this checks to see if the cookie exists
var begin=location+11;
//this gets the location of the begining of the surfer's name
var yourname=thiscookie.substring(begin, endlocation);
//this grabs the value from the cookie
yourname = unescape(yourname);
//this unencodes the surfer's name
return yourname;
//this returns the surfer's name
}
else{
var yourname = prompt("Welcome, please enter in your name.",'');
//this asks for the name
document.cookie = "surfername=" + escape(yourname)+":" + "expires=Fri Dec 10 11:00:00 PST 1999";
// the above line sets the cookie with a name=value pair of surfername=value
// you may modify the expiration date by changing the expires=
}
return yourname; //this returns the surfer's name
}
</SCRIPT>

part to of the script

Code:
<SCRIPT> 
document.write("Welcome to my site, " + getname() + "!"); 
</SCRIPT>



hey how can i change the font colour and font size in this script...
 

GTRZ

Administrator
Staff member
  • Apr 27, 2006
    19,480
    10,860
    113
    Script not complete so can’t say, anyway you looking for a java script which ask for the name using a small popup then you can’t change the colour coz it’s coming from the browser.
    Tell me what you wanna do?
     
    • Like
    Reactions: Charlie Babbitt

    GTRZ

    Administrator
    Staff member
  • Apr 27, 2006
    19,480
    10,860
    113
    ============================================================
    Script: Ask Visitor For Name Script

    Functions: A very simple paste-it-in script that asks the
    vistor for his or her name when entering your
    page, then prints a "Hello" welcome message
    anywhere you wish in the body of the page.
    If the visitor does not type in a message,
    a default message shows, instead. Very easy
    install for JavaScript newcomers.

    Browsers: NS3-6, IE4-6

    Author: etLux
    ============================================================

    INSTRUCTIONS:

    Paste the following <script> ... </script> block into the
    <body> (notice we said the body, *not* the <head>) of
    your page, exactly where you would like the message to
    appear.

    <script>

    var whatName=prompt("Please type in your name:","");
    function doName(theName){
    if ((whatName != "")&&(whatName !=null)){
    // you can modify this as needed
    // this is the message if a name is typed in
    document.writeln("Hello "+whatName+"!")
    }else{
    // you can modify this as needed
    // this is the message if a name is *not* typed in
    document.writeln("Hello!")
    }
    }

    doName(whatName);

    </script>

    ============================================================

    Design Notes:

    1.

    When you use an in-the-body script like this, you will
    usually want to format the text it prints into the page.

    This is simple enough to do -- just surround the the
    <script> ... </script> block with font tags, like this:

    <font face="Arial" size="2" color="#FF0000">
    <script>
    .
    .
    .
    </script>
    </font>

    Change the face, size, and color to match your design.

    2.

    You may not, of course, want to use the "Hello Name!"
    message we show. See the two commented lines in the script
    above for where you can change the message.

    ============================================================

    hope this helps, you can change the colour, font, size everything in this.. :yes:
     
    Code:
    <SCRIPT> 
    document.write("Welcome to my site, " + getname() + "!"); 
    </SCRIPT>

    the above was the secont part of my original script.. all i had to do is
    add
    Code:
    <font face="Arial" size="2" color="#FF0000">
    <script>
    .
    .
    .
    </script>
    </font>



    the full script wud..be (secind part of my script

    Code:
    <font face="Arial" size="2" color="#FF0000">
    <SCRIPT> 
    document.write("Welcome to my site, " + getname() + "!"); 
    </SCRIPT>
    </font>

    the font part to it wel i trid that in front page and it workd i will be addin it to my site to nite which is http://www.deffa12e.tk

    plese tel me how it is..
     
    this is what GRTZ gave me

    Code:
    <script>
    
    var whatName=prompt("Please type in your name:","");
    function doName(theName){
    if ((whatName != "")&&(whatName !=null)){
    // you can modify this as needed
    // this is the message if a name is typed in
    document.writeln("Hello "+whatName+"!")
    }else{
    // you can modify this as needed
    // this is the message if a name is *not* typed in
    document.writeln("Hello!")
    }
    }
    
    doName(whatName);
    
    </script>

    same as above jus had to add the font part

    the final script luks like
    Code:
    <font face="Arial" size="2" color="#FF0000">
    <script>
    
    var whatName=prompt("Please type in your name:","");
    function doName(theName){
    if ((whatName != "")&&(whatName !=null)){
    // you can modify this as needed
    // this is the message if a name is typed in
    document.writeln("Hello "+whatName+"!")
    }else{
    // you can modify this as needed
    // this is the message if a name is *not* typed in
    document.writeln("Hello!")
    }
    }
    
    doName(whatName);
    
    </script>
    </font>

    wel both of the scripts worked...thanks GTRZ