Results 1 to 7 of 7

Thread: Document Write instead of Alert

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Document Write instead of Alert

    I found this script off of someother site... here it is:
    Code:
    function had(){
    loggedin=false;
    username="";
    password="";
    username=prompt("Username:","");
    username=username.toLowerCase();
    password=prompt("Password:","");
    password=password.toLowerCase();
    if (username=="1" && password=="1") { 
    loggedin=true;
    window.location="home.html";
    }
    if (username=="Username" && password=="Password") {
    loggedin=true;
    window.location="home.html";
    }
    if (loggedin==false) {
    alert("Hi");
    }
    }
    this is js file. I want the alerts and window.locations to change to document.writes. cuz I want it to say... "Correct" or "Incorrect"... I DON'T WANT TO CHANGE PAGES!

    thanks all

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Not tested, and not sure if this is what you mean, but here you go.

    Code:
    function had(){
    loggedin=false;
    username="";
    password="";
    username=prompt("Username:","");
    username=username.toLowerCase();
    password=prompt("Password:","");
    password=password.toLowerCase();
    
    if (username=="1" && password=="1") { 
    loggedin=true;
    document.write('Correct');
    }
    
    if (username=="Username" && password=="Password") {
    loggedin=true;
    document.write('Correct');
    }
    
    if (loggedin==false) {
    document.write('Incorrect');
    }
    
    }
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You are aware that this provides no security whatsoever, correct?

    Using document.write() might also break your page, depending on how and where the had() function is called.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    I no, its a small scale website, thats going to be encrypted, yada yada...

  5. #5
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    The testing site, hey, this thing isn't working, twedy u said about something about placement... where might it work. this is going into a form.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I no, its a small scale website, thats going to be encrypted, yada yada...
    Still doesn't provide any protection unless you involve something server-side, even if it's just URL obfuscation (see here for an example).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Oh i got it to sorta work, but i sorta want it 2 make the document write on the same page, not a different page... lol

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •