56 users online (1 members and 55 guests)  


  Results 1 to 3 of 3

Related

  1. how to stop javascript via another javascript    Forum: Javascript Forum
    Replies: 0
  2. Replies: 8
  3. Replies: 5
  4. Frames    Forum: HTML Forum
    Replies: 1
  5. frames help    Forum: HTML Forum
    Replies: 1
  1. #1
    omathewonder's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2003
    Location
    Washington, DC
    Posts
    8

    javascript and frames

    i must admit i do not really know javascript much, and that i copied this javascript from a free site. it is a password script with multiple users, passwords and destination pages. It works perfectly, except that I have my log-in on a frames page and after logging in, a new window opens outside of the frames.

    I really would like help with the script so that the user is kept inside the frames after logging in.

    I'm pretty sure this is the line in the script that affects the destination page:

    top.location=page.toLowerCase()+".html";

    but here is the whole script in case you need more... any help would be much appreciated!

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var params=new Array(4);
    var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
    function check(form) {
    which=form.memlist.selectedIndex;
    choice = form.memlist.options[which].value+"|";
    if (choice=="x|") {
    alert("Please Select Your Name From The List");
    return;
    }
    p=0;
    for (i=0;i<3;i++) {
    a=choice.indexOf("|",p);
    params[i]=choice.substring(a,p);
    p=a+1;
    }
    h1=makehash(form.pass.value,3);
    h2=makehash(form.pass.value,10)+" ";
    if (h1!=params[1]) {
    alert("Incorrect Password!"); return; };
    var page="";
    for (var i=0;i<8;i++) {
    letter=params[2].substring(i,i+1)
    ul=letter.toUpperCase();
    a=alpha.indexOf(ul,0);
    a-=(h2.substring(i,i+1)*1);
    if (a<0) a+=26;
    page+=alpha.substring(a,a+1); };
    top.location=page.toLowerCase()+".html";
    }
    function makehash(pw,mult) {
    pass=pw.toUpperCase();
    hash=0;
    for (i=0;i<8;i++) {
    letter=pass.substring(i,i+1);
    c=alpha.indexOf(letter,0)+1;
    hash=hash*mult+c;
    }
    return(hash);
    }
    // End -->
    </script>

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    moving to javascripts forum

  3. #3
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hey, you have done most of the work yourself

    You right, that line is the one breaking you out of the frames.

    I don't want to test this one myself, as its all passwordy and stuff, but try -

    Code:
    top.location=page.toLowerCase()+".html";
    CHANGE TO
    Code:
    location=page.toLowerCase()+".html";
    Failing that, try

    Code:
    this.location=page.toLowerCase()+".html";
    But the first should work.

    As a warning, a JavaScript login/password system is about as secure as Windows 98. Consider a server-side language replacement.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread