Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19302 > unrolled thread

Pass username to a new html file

Started by"Tony" <tony.johansson@inport.com>
First post2013-04-17 13:49 +0200
Last post2013-04-18 02:48 -0700
Articles 3 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Pass username to a new html file "Tony" <tony.johansson@inport.com> - 2013-04-17 13:49 +0200
    Re: Pass username to a new html file Stefan Weiss <krewecherl@gmail.com> - 2013-04-18 00:57 +0200
    Re: Pass username to a new html file Bart Van der Donck <bart@nijlen.com> - 2013-04-18 02:48 -0700

#19302 — Pass username to a new html file

From"Tony" <tony.johansson@inport.com>
Date2013-04-17 13:49 +0200
SubjectPass username to a new html file
Message-ID<kkm23m$2ah$1@dont-email.me>
I use function GotrisLogin in Login.html to display a page with username and 
password.
If succsessful login I display a new page by  using window.location.href = 
"Obstacle.html";
This works good.
Now in the new html page "Obstacle.html"  I need the entered username from 
login.html.

How can I pass the entered username from login.html to Obstacle.html ?

function GotrisLogin()
        {
            gotris_login($('#txtUserName').val(), $('#txtPassWord').val(), 
function (data, textStatus, jqXHR)
            {
                //If successful login set cookie and switch html page
                if (IsOkMessageShort(data.dsError))
                {
                  window.location.href = "Hinder.html";
                }
            });
        }

//Tony 

[toc] | [next] | [standalone]


#19320

FromStefan Weiss <krewecherl@gmail.com>
Date2013-04-18 00:57 +0200
Message-ID<kkn9c1$ohc$1@news.albasani.net>
In reply to#19302
On 2013-04-17 13:49, Tony wrote:
> I use function GotrisLogin in Login.html to display a page with username and 
> password.
> If succsessful login I display a new page by  using window.location.href = 
> "Obstacle.html";
> This works good.
> Now in the new html page "Obstacle.html"  I need the entered username from 
> login.html.
> 
> How can I pass the entered username from login.html to Obstacle.html ?
> 
> function GotrisLogin()
>         {
>             gotris_login($('#txtUserName').val(), $('#txtPassWord').val(), 
> function (data, textStatus, jqXHR)
>             {
>                 //If successful login set cookie and switch html page
>                 if (IsOkMessageShort(data.dsError))
>                 {
>                   window.location.href = "Hinder.html";
>                 }
>             });
>         }

You're leaving out a lot of information here... As a shot in the dark,
it looks like you're authenticating against a server, but at least some
of your HTML documents are completely static. That's an uncommon
solution, and you'll likely run into the same question (how to
communicate between static documents) throughout the rest of the
application.

If this is how your project works, your main options would be URL
parameters, asking the server, and maybe using frames. Cookies and
session storage might be options, but are unreliable/unavailable when
your HTML files are loaded directly from the local file system (depends
on the browser).

Regarding your example, if you want to pass data to Obstacle.html, it
would be a start to actually load Obstacle.html instead of Hinder.html.

- stefan

[toc] | [prev] | [next] | [standalone]


#19327

FromBart Van der Donck <bart@nijlen.com>
Date2013-04-18 02:48 -0700
Message-ID<420e1adc-a7cd-4d2a-b585-fc56a2bcde0c@googlegroups.com>
In reply to#19302
Tony  wrote:

> I use function GotrisLogin in Login.html to display a 
> page with username and password.
> If succsessful login I display a new page by  using 
> window.location.href = "Obstacle.html";
> This works good. 
> Now in the new html page "Obstacle.html"  I need the 
> entered username from login.html.
> How can I pass the entered username from login.html 
> to Obstacle.html ?

login.htm:

  <form method="get" action="obstacle.html">
   <input type="password" name="password">
   <input type="submit">
  </form>

obstacle.htm:
 
  alert(window.location.search);

But the level of security is low because the URL of the protected page is present in the page source itself.

It would be a lot safer to perform your redirect based upon the value of the password. Eg. use 'Hinder' as a password, and then redirect to [password].html, after a 404-check with XmlHttpRequest.

Hope this helps,

-- 
 Bart

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web