0

What's the wrong with this Javascript line?

user: h.reem
domain: somedomain

var target = "//account/win/winlogin.aspx" + 
             "?username=" + 
             user.toString() + 
             "&domain=" + 
             domain.toString();

the resutl is always:

//account/win/winlogin.aspx?username=h.reem

Any idea!!

enter image description here

10
  • 2
    Not for me: jsfiddle.net/92R99/1 . What are user and domain? properties of an object? Are they strings? Show us the definition of those. Commented Aug 8, 2011 at 13:13
  • why don't you try using domain and user instead of domain.toString and user.toString ? As I feel that domain and user are strings! Commented Aug 8, 2011 at 13:14
  • your jsfiddle alerts '//account/win/winlogin.aspx?username=h.reem&domain=somedomain' here Commented Aug 8, 2011 at 13:15
  • @Matt: These values (user) & (domain) are coming from ActiveX. When I wrote them as you wrote (hard codded) then it worked well, but in my case it does not work! Commented Aug 8, 2011 at 13:16
  • 1
    @French: You might want to update your question and say that ;)... It's quite crucial! I've never used ActiveX, so can't help you any further I'm sorry... but someone else will be able to! Commented Aug 8, 2011 at 13:18

2 Answers 2

2

alert(user + "X") shows only h.reem

The ActiveX component is probably returning a null terminated string (I've seen this with Scripting.TypeLib & a couple of the AD objects for example) so concatenating it with another string fails. (You can verify this if 0 === user.charCodeAt(user.length - 1)).

You will need remove the last character before using the string;

user = user.substr(0, user.length - 1);

Sign up to request clarification or add additional context in comments.

Comments

0

try:

var sUser = user.toString();
var sDomain = domain.toString();

var target = "//account/win/winlogin.aspx" + "?username=" + sUser + "&domain=" + sDomain;

The above might not fix your problem but it should expose it - Could be that your user.toString() method isn't returning a string and is short-circuiting things... If this doesn't answer your question I'd be glad to assist further, but it would be helpful if you posted the implementation or source of "user" somewhere ...

1 Comment

Thanks for your answer. It doesn't work. I added a screen-shot from my code. Kindly see it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.