Solved

ASP code inside the JavaScript

Posted on 2003-11-03
63
1,286 Views
Last Modified: 2008-03-03
Hello,

I am trying to make a HEAD request to IIS Server using the Java Script and MSXML. I cannot get the value from the HTTP Header. The JavaScript I used is below.

But I can able to use ASP to get the variable "sm_user". (when user login to the application, the valid userID is stored into sm_user variable.) using the following I can able to get the sm_user value easily in the ASP

<%=Request.ServerVariables("sm_user")%>


Now my question is, Can I use this ASP code inside the JavaScript. Once I receive the value from the asp, I can pass it to my javaScript.



function getUserId(){
     //-------------------------------------------------------------------------
     //
     //           Querying the HTTP-Header (IIS Server) using MSXML 2.0
     //
     //-------------------------------------------------------------------------
     //Creating the Object
     var myUser
     var xmlhttp
     /*@cc_on @*/

     /*@if (@_jscript_version >= 5)
            try {
             xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
            } catch (e) {
              try {
               xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
              } catch (E) {
               xmlhttp=false
              }
            }
       @else
            xmlhttp=false
       @end @*/
       if (!xmlhttp) {
           try {
            xmlhttp = new XMLHttpRequest();
           } catch (e) {
            xmlhttp=false
           }
       }

      xmlhttp.open("HEAD", "/index.html",true);
      xmlhttp.onreadystatechange=
           function() {
               if (xmlhttp.readyState==4) {
                    alert("The login userId is - "+
                         xmlhttp.getResponseHeader("sm_user"))
                  myUser = xmlhttp.getResponseHeader("sm_user")
               }
           }
      xmlhttp.send(null);
      return myUser;
 }

I would appreciate your help. Its very important for me. if you answer ASAP.

kalagappan
0
Comment
Question by:alagappanK
  • 34
  • 24
63 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 9674507
As I said before, this is the answer:

<%

dim strVariable
strVariable = "Some text"

%>

<SCRIPT LANGUAGE=javascript>
<!--
var strSomeVariable = "<%=strVariable%>";

//-->
</SCRIPT>


FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9674508
For those who want to follow what has been said so far:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20786536.html

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9674519
Look, let's go through this step by step. If you would please trust me and do exactly what I ask, I will get you there.

What do you get when you do:

<%=Request.ServerVariables("sm_user")%>


I need to see what the value looks like.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9674534
if you want the value that is returned from the function, do this:

<%
strUser = getUserId()
%>

Then for client side, you do this:

<SCRIPT LANGUAGE=javascript>
<!--
var strUser= "<%=strUser%>";

//-->
</SCRIPT>


FtB

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9674546
If you are trying to get the value for <%=Request.ServerVariables("sm_user")%>, then just do this:


<%
strUser=Request.ServerVariables("sm_user")
%>

<SCRIPT LANGUAGE=javascript>
<!--
var strUser= "<%=strUser%>";

//-->
</SCRIPT>

0
 

Author Comment

by:alagappanK
ID: 9674629
Do not mistaken me Mr. fritz_the_blank for posted in the ASP Forum. All I am trying to fix it faster.

Well, I have to code this inside the javaScript. I am not allowed to write any ASP in this project.

I tried the code you provided inside the JavaScript. I have many javaScript function doing other things. To acheive other stuff, I need the userID. To get the userID, I thought I can use the xmlhttp. But it doesn't work. I am wondering if I can use the "ASP inside the javascript"

thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9674712
Are you allowed to run .asp pages? If not, then you can't use the asp value in the javascript. If you can use asp pages, then you can get the userID like this:

<%
strUser=Request.ServerVariables("sm_user")
%>

<SCRIPT LANGUAGE=javascript>
<!--
var strUser= "<%=strUser%>";

//-->
</SCRIPT>


FtB
0
 

Author Comment

by:alagappanK
ID: 9687469
Hello,

Sorry for not responding you. I spoke to my team mates and they agree that, I can use ASP for this situation.

Can you help me this.

I can create a ASP page and use the code above. I need to get this "strUser" to the other JavaScript file.  What I mean is I have a set of javaScript function in a file. I need this value in there. Would you please tell me how to do that.

I apologize for all the confusion.

Thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9687487
Sure. Is it possible to pass this value as a parameter to your JavaScript funciton?

FtB
0
 

Author Comment

by:alagappanK
ID: 9687718
Yes, I can make changes in the JavaScript code to accept a value as parameter. Would you please tell me how to call the ASP Page from javascript. what I am asking is It would be great if you can give me the code (atlease some kind of skeleton)

thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9687776
Please tell me the name of your include file for the JavaScripts and I'll put together a page for you.


FtB

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9688759
Well until then, here is a sample for you:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
      <title></title>
<%
function getUserId(){
     //-------------------------------------------------------------------------
     //
     //           Querying the HTTP-Header (IIS Server) using MSXML 2.0
     //
     //-------------------------------------------------------------------------
     //Creating the Object
     var myUser
     var xmlhttp
     /*@cc_on @*/

     /*@if (@_jscript_version >= 5)
            try {
             xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
            } catch (e) {
              try {
               xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
              } catch (E) {
               xmlhttp=false
              }
            }
       @else
            xmlhttp=false
       @end @*/
       if (!xmlhttp) {
           try {
            xmlhttp = new XMLHttpRequest();
           } catch (e) {
            xmlhttp=false
           }
       }

      xmlhttp.open("HEAD", "/index.html",true);
      xmlhttp.onreadystatechange=
           function() {
               if (xmlhttp.readyState==4) {
                    alert("The login userId is - "+
                         xmlhttp.getResponseHeader("sm_user"))
                  myUser = xmlhttp.getResponseHeader("sm_user")
               }
           }
      xmlhttp.send(null);
      return myUser;
 }
%>

<script>
<!--
var strMyUser ="<%=getUserID%>"

function sayHiToUser(strUserName){
      alert("Hello " + strUserName);
}

window.onLoad=sayHiToUser(strMyUser);


//-->
</script>
</head>

<body>



</body>
</html>
0
 

Author Comment

by:alagappanK
ID: 9689089
I cannot rename my JavaScript file to ASP file. Would you please tell me is it possible to have the ASP file with the function getUserID() and I have a JavaScript file called whphost.js

Can I call the getUSerID() from whphost.js file.

One more thing is that, I tried this function in my javascript and it is not getting the inbound HTTP Header values from IIS Server.

I would appreciate your help,
thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9689149
Well, that should be possible, but try to keep clear in your mind what happens client side and what happens server side....

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<!-- #include file="whphost.js" -->
<SCRIPT LANGUAGE=javascript>
<!--
var strMyUser ="<%=getUserID%>"
//-->
</SCRIPT>


</HEAD>
<BODY>

<P>&nbsp;</P>

</BODY>
</HTML>
0
 

Author Comment

by:alagappanK
ID: 9689348
It may be dumb question. But, would you please tell me why can't we use this following function in JavaScript ??? Any Idea ??

function getUserId(){
     //-------------------------------------------------------------------------
     //
     //           Querying the HTTP-Header (IIS Server) using MSXML 2.0
     //
     //-------------------------------------------------------------------------
     //Creating the Object
     var myUser
     var xmlhttp
     /*@cc_on @*/

     /*@if (@_jscript_version >= 5)
            try {
             xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
            } catch (e) {
              try {
               xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
              } catch (E) {
               xmlhttp=false
              }
            }
       @else
            xmlhttp=false
       @end @*/
       if (!xmlhttp) {
           try {
            xmlhttp = new XMLHttpRequest();
           } catch (e) {
            xmlhttp=false
           }
       }

      xmlhttp.open("HEAD", "/index.html",true);
      xmlhttp.onreadystatechange=
           function() {
               if (xmlhttp.readyState==4) {
                    alert("The login userId is - "+
                         xmlhttp.getResponseHeader("sm_user"))
                  myUser = xmlhttp.getResponseHeader("sm_user")
               }
           }
      xmlhttp.send(null);
      return myUser;
 }
0
 

Author Comment

by:alagappanK
ID: 9689356
If I can make this work with the javascript. It would be great !!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9689501
That code has to run with server-side JavaScript, not client-side JavaScript (at least that is what I am guessing--I don't much work with server-side JScript).

FtB

0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 9692758
what is the error that you get when you execute the above javascript (getUserID) function?.

Make sure that you have enabled your browser to allow scripts not marked as safe. (Go to Tools>Internet Options>Security>Custom Level>Initialize and Script Activex Controls Not Marked as Safe ... Click on Prompt.).

Also, I assume that you are aware of the fact that only IE would support the code that you have written above.

Cheers!!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9694653
I am still confused about whether this code is supposed to be server-side or client side? From the orginal question, it looks like it was designed to grab a user id via server-side scripting. If that is not the case, and this is client side scripting, then that changes the whole question.

FtB
0
 

Author Comment

by:alagappanK
ID: 9694784
Mr. fritz_the_blank.

Its my mistake. I suppose to tell you this. I am trying to use the above code from my client side javascript.

I do not want to use the serverside javascript. I apologize for the inconvenience. Please let me know, what needs to be done to make it work. If I use the the code like

<%@ language="javascript" %>
<script language="javascript" runat="server" >
   Response.Write("This is a server-side messgae");
</script>

if I use this code in my client side script, do you think it work ??

thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9694879
If you do this on the client side:

<%@ language="javascript" %>
<script language="javascript" runat="server" >
   Response.Write("This is a server-side messgae");
</script>


it will not work. On the other hand, if you change the code, it will:

<SCRIPT LANGUAGE=javascript>
<!--
document.write("This is a client-side messgae");

//-->
</SCRIPT>

it will.

This thread has been going on for a while, and I don't think that I have been doing a very good job at helping you.

Let's try to clarify the problem so that I can do a better job.

1) What is it exactly that you are trying to accomplish?
2) Can you use server-side asp code? If so, what language do you program that in, JScript or VBScript?

FtB

0
 

Author Comment

by:alagappanK
ID: 9717159
Hello,

I am trying to query the HTTP Header for UserID in IIS Server from clientside javascript. This IIS Server is secured by SiteMinder software. We are using RoboHelp for presentation. RoboHelp is installed in IIS Server. RoboHelp is a software which provide the framework for presentation of online help or online application. We are allowed to use as a "black-box" implementation. That is the reason I am trying to avoid ASP.

In the RoboHelp software, the use many javascript. I modifed one javascript to include the userID. If I use ASP, how do I accomplish, getting the UserID in ASP and then How do I get the userID value from the JavaScript.

Remember I can not include this javascript inside the ASP, because this javascript is refered in may programs in the RoboHelp.

To answer to your second question, I am trying to use JavaScript. If I can fix my problem using ASP, I can use JScript.

Can you please tell me something, if I use ASP and have function which return the UserID. and now, can I call this function from javaScript (this javascript is not inside the ASP)

I greatly appreciat your patience and help,

alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9717376
Okay, let's go one step at a time.

I think that from what you say above that you will need to use at least some server-side script, otherwise, I think it unlikely that you will be able to get http header information about the UserID.

So, you will have to use at least some .asp to get the user id.

Do you have a piece of code that you currently use to get the id? If so, is it that  getUserId() function?

FtB
0
 

Author Comment

by:alagappanK
ID: 9717892
I can use the following code inside the ASP to get the userID.

<%
var userID;
userID = response.write(Request.ServerVariables("sm_user"))

%>

would you please help me here to give me the full ASP Code (function and that return this userID). I appreciate that.

Then the second step is, From my javaScript, I should be calling this function to bring the userID value to my javaScript. I am not sure how to do it.

thank you so much for your help,

alagappank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9718073
Okay, so you know how to get the user id. That's great!

Now, do you want this value for server-side JavaScript code or for client-side javascript code? If the latter, try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
      <title>Untitled</title>
<%
var userID;
userID = response.write(Request.ServerVariables("sm_user"))
%>

<script>
<!--
function showUser(intUserID){
      alert(intUserID);
}
//-->
</script>
</head>

<body onLoad=showUser('<%response.write(Request.ServerVariables("sm_user"))%>')



</body>
</html>

0
 

Author Comment

by:alagappanK
ID: 9718254
Thank you very much fritz_the_blank.

I want the userID for my client side javascript.
Would you please give me a sample code of how clientside javascript can call the above function(showUser) in ASP.

Thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9718283
Take a look at the example above...

In general, you can do this:

<script>
<!--
var intUserID;
intUserId= <%response.write(Request.ServerVariables("sm_user"))%>

//-->
</script>

now you can use the variable intUserID for all of your client-side scripts.

FtB
0
 

Author Comment

by:alagappanK
ID: 9718344
Are you saying from my Javascript (whphost.js) I can use this code to get the UserID

<script>
<!--
var intUserID;
intUserId= <%response.write(Request.ServerVariables("sm_user"))%>

//-->
</script>


Here is the thing,

I want to keep the ASP separate.
I wanted to call the function in the ASP page from my whphost.js
The reason is that, I have alot of javascript is in this whphost.js,  and it is refered in may places.

If I confuse you, please let me know

alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9718477
Keep in mind that the scope of any client-side javascript variable is only for the page. For each page that you want to use the server-side variable, you will have to do the following:

<script>
<!--
var intUserID;
intUserId= <%response.write(Request.ServerVariables("sm_user"))%>

//-->
</script>


Once you do that, you can use the client-side variable in all of your client-side  scripts.

Are all of the scripts in whphost.js client side scripts? If so, once you execute the code above, you can use the variable in your whphost.js scripts as well.

Don't forget, however, that client-side variables expire with the unLoad() event of your page, so, you will have to grab the value for each page where you want to do this.

FtB
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:alagappanK
ID: 9722816
Hello Good Morning FtB,

I understand that, I have to use the  one line of code for each page. But this javascript is not used for every page. If I get this userID, it will be set as global variable for this javascript (whphost.js), If I call this script again, I need to run the one line of code.

Yes All the scripts in whphost.js is client side scripts.

The following is not clear to me.
-------------------------------------
Can you please clarify me this. The following code will be inside the clientside javascript ?? I am just wondering since we have <%%> tag, does it work inside the javascript ??

If I have to use this code inside the ASP. Can you tell me how do I get this value out of ASP to my JavaScript(whphost.js).

<script>
<!--
var intUserID;
intUserId= <%response.write(Request.ServerVariables("sm_user"))%>

//-->
</script>

Thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9724428
For each page where you intend to use scripts from whphost.js and you need the variable, you will need to run the following code:

<script>
<!--
var intUserID;
intUserId= <%response.write(Request.ServerVariables("sm_user"))%>

//-->
</script>

That is because the variable scope will only last for the page. You cannot set it as a global variable that outlasts the page.


AS for using server-side tags with client-side script, you can do it if you keep clear in your mind what happens where and in what order. Please try this simple example so that you will understand. I know I keep repeating this, but if you can understand this, the rest will be clear. The idea is that you set the variable with server-side code. When the page renders, it will grab the server-side script. Here is what the page looks like on your server:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<%
var strName = "Fritz the Blank";
%>
<SCRIPT LANGUAGE=javascript>
<!--
function sayHello(){
     alert("Hi " + "<%=strName%>");
}
//-->
</SCRIPT>

</HEAD>
<BODY onLoad=sayHello()>

<P>&nbsp;</P>

</BODY>
</HTML>


This is what the page will look like if you view the source once you run it:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>

<SCRIPT LANGUAGE=javascript>
<!--
function sayHello(){
     alert("Hi " + "Fritz the Blank");
}
//-->
</SCRIPT>

</HEAD>
<BODY onLoad=sayHello()>

<P>&nbsp;</P>

</BODY>
</HTML>
0
 

Author Comment

by:alagappanK
ID: 9724779
okay. I wanted to tell you this. I am running these whphost.js and other javascript before I get into the initial web page(index.html). So, this javascript do all the initial task, it nothing related to web page.

If I include the code with <%%> tags in my javascript, it works ?? I guess the answer is yes. In that case I don't need any ASP page ???

Please let me know.
thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9726368
How can anything happen in whphost.js before a page is called? If it is client-side javascript, it needs to be called from some page, doesn't it?

In any case, you can try putting the snippet into your .js include file and see what happens.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9726374
If you do that, however, the first time that you call an .htm page with that include file, it will crash because the snippet requires .asp.

FtB
0
 

Author Comment

by:alagappanK
ID: 9732197
Good Morning FtB,

I understand what you saying. would you please be patience here. I know this thread is going way longer. Let me explain, little bit more..

Once this Application is called, This Presentation (RoboHelp) need to intialize its parameter such as where is the data file (xml) and html file. For different user, depending upon their access level, they access different directory.
So, I use this userID to get this directory structure (where the data and html file is located). This is the business logic.

All the above is happening, once the user request for the page. Once the RoboHelp find the path, it will render the HTML to the client browser. I am just trying to modify the RoboHelp JavaScript to include few code, to use the UserID to get the right directory path for the given USER.

I believe I told you about the security, SiteMinder, its installed on ther server. ONce user access this application, this siteMinder will provide the user login screen, user type there user Name and password, it goes to siteMinder and it validate the user and then forward the request to this RoboHelp, Here I need to get this userID and find the directory path for this userID.

I know its a long process. let me know if it make sense.

thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9732221
This is really difficult since I can't test code in your environment....

If you think about the principles that we learned through this and the other thread, can you figure out how to apply them to what you  are trying to accomplish here?

I am guessing that the place to start testing is with the authentication routine. Since the user's level is set there, that is probably the first place that you will need to do this.

FtB
0
 

Author Comment

by:alagappanK
ID: 9749385
Can you please tell me this following code in ASP is right or if you find any syntax error or any escape character error, please let me know.

I am trying to get the value of HTTP_HOST into this variable windowsUserName, I can use this variable in my JavaScript.


<%
response.write("windowsUserName = ''" + Request.ServerVariables ( 'HTTP_HOST' ) + "'';")
%>


I truly appreciate your help,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9749417
<%
response.write("windowsUserName = '' + Request.ServerVariables ( 'HTTP_HOST' ) + '';")
%>


FtB
0
 

Author Comment

by:alagappanK
ID: 9750005
Hello FtB,

I am including this ASP like below. The above ASP is called "getMyUserName.asp"

In the html I include this line
<html>
...

<script language="JavaScript1.2" src="getMyUserName.asp"></script>
<script language="javascript1.2" src="whphost.js"></script>

<script>
alert(" Here is the value " + windowsUserName);
</script>
...

</html>

when I run this, I am getting the Error: 'windowsUserName' is undefiened

I appreciate your help to fix it. I was guessing that this windowsUserName is already initialized in the ASP Page.

Thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9750057
Change this:

<script language="JavaScript1.2" src="getMyUserName.asp"></script>
<script language="javascript1.2" src="whphost.js"></script>

To:

<!-- #include file="getMyUserName.asp" -->
<script language="javascript1.2" src="whphost.js"></script>


Also, what does getMyUserName.asp look like?

FtB
0
 

Author Comment

by:alagappanK
ID: 9750319
getMyUserName.asp looks like below

<%
response.write("windowsUserName = " + Request.ServerVariables ('HTTP_HOST') + ";")
%>

Let me know,
thank you,
alagappan Kennedy
0
 

Author Comment

by:alagappanK
ID: 9750362
In my html code I use the following as you mentioned to me earlier

<html>
...
...
<!-- #include file="getMyUserName.asp" -->
<script language="javascript1.2" src="whphost.js"></script>
...
<script>
alert(" Here is the value " + windowsUserName);
</script>
...

</html>

getMyUserName.asp looks like below

<%
response.write("windowsUserName = " + Request.ServerVariables ('HTTP_HOST') + ";")
%>

when I run this, I am still getting this  

Error: 'windowsUserName' is undefiened

thank you for helping me. please let me know,

alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9750400
I think that I see the problem.

getMyUserName.asp should be:



<%
response.write("var windowsUserName = " + Request.ServerVariables ('HTTP_HOST') + ";")
%>


FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9750416
Hang on, that should be:


<%
Response.write("<script language='javascript1.2'>")
response.write("var windowsUserName = " + Request.ServerVariables ('HTTP_HOST') + ";")
response.write("</script>")
%>

0
 

Author Comment

by:alagappanK
ID: 9750551
I just modified the ASP Code. its still giving me the same Error: 'windowsUserName' is undefiened.

I am just don't know what other reason its not recognizing the variable.

It is not complaining about the ASP at all. Do you think its ignoring the ASP ?? that we included

thank you
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9750575
Whe you run the page, view the source, and paste the result here. That way we will be able to see what is happening.

FtB
0
 

Author Comment

by:alagappanK
ID: 9750740
I have few frame in my presentation layer. This is the html which uses the code I am talking about.

<html>
<head>
<title> Navigation Pane </title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="RoboHelp by eHelp Corporation   www.ehelp.com">
<meta name "description" content="WebHelp 5.10">
</head>
<body border=0 topmargin=0 bottommargin=0 rightmargin=0 leftmargin=0 scroll=no>
<script language="javascript" src="whver.js"></script>
<script language="javascript1.2" src="whmozemu.js"></script>
<script language="javascript1.2" src="whmsg.js"></script>
<script language="javascript1.2" src="whproxy.js"></script>
<script language="javascript1.2" src="whutils.js"></script>
<!-- #include file="getMyUserName.asp" -->
<script language="javascript1.2" src="whphost.js"></script>
<script language="javascript1.2">
<!--
alert(" Here you go !!! " + windowsUserName);
if (window.gbWhPHost)
{
      var gsNavReDirect="whskin_plist.htm";
      var gbReDirectThis=true;
      var oMsg = new whMessage(WH_MSG_GETPANES, this, 1, null);
      if (SendMessage(oMsg))
      {
            if (oMsg.oParam)
            {
                  for (var i=0;i<oMsg.oParam.aPanes.length;i++)
                  {
                        addPane(oMsg.oParam.aPanes[i].sPaneName, oMsg.oParam.aPanes[i].sPaneURL);
                  }
                  setShowPane(oMsg.oParam.sDefault);
                  setServerEnabled();
            }
            else
                  writeWebHelpPane();
      }
      else
            writeWebHelpPane();
}
else
      document.location.reload();

if (window.gbNav6)
{
      var oMsg=new whMessage(WH_MSG_RELOADNS6,this, 1,null);
      SendMessage(oMsg);
}


function writeWebHelpPane()
{
  var bPreferXML            = false;
  var strProjectFileXML =  "whproj.xml";
  var strProjectFileHTM =  "whproj.htm";
  addProject(bPreferXML, strProjectFileXML, strProjectFileHTM);
  addPane("toc","whtdhtml.htm");
  addPane("idx","whidhtml.htm");
  addPane("fts","whfdhtml.htm");
  addPane("glo","whgdhtml.htm");
  setShowPane("toc");

}
//-->
</script>
</body>
</html>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9750781
Okay--this isn't good! The problem is right in the second line:

<script language="javascript1.2" src="whutils.js"></script>
<!-- #include file="getMyUserName.asp" -->
<script language="javascript1.2" src="whphost.js"></script>


That code should be processed. It looks like you are running this page as an .htm page rather than as an .asp page.

FtB
0
 

Author Comment

by:alagappanK
ID: 9750955
Yes. this whole code is inside the htm file. I thought I can include ASP page inside the htm.

Are you saying it is not possible to use ASP Page inside the htm file.

If I have to change file name from .htm to .asp then I have to change the name where ever it refering this file.

Is there any other way ???
Thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9751011
I am afraid that there is no other way! You can neither execute asp code nor include an asp file unless your page is .asp.

We went over this a few times already, right?

FtB
0
 

Author Comment

by:alagappanK
ID: 9751039
hmm.. The issue is that, I cannot change the htm file to asp. Because it is been tie with the other files. I am not sure this RoboHelp allow to use ASP Pages.

I just have to investicate to see if I can use asp instead of htm  then !!!!

thank you,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9751157
You will have to because the whole point where this question started was the need to pass server-side asp values to client-side code, and the only way that can work is by running asp.

FtB
0
 

Author Comment

by:alagappanK
ID: 9751372
Hello  FtB,

It works just fine with the following code. I just found a syntax mistake in the ASP code, that fix the whole thing.

<html>
...

<script language="JavaScript1.2" src="getMyUserName.asp"></script>
<script language="javascript1.2" src="whphost.js"></script>

<script>
alert(" Here is the value " + windowsUserName);
</script>
...

</html>

getMyUserName.asp should be:

<%
response.write("var windowsUserName = " + "'" + Request.ServerVariables("HTTP_HOST") + "'")
%>

I just miss the double quotation for HTTP_HOST. Instead I used single Quotation.  So, we can include the ASP in the htm file and after the execution of the ASP we will get

var windowsUserName = xxx

I can use this "windowsUserName" variable in my javascript to continue my processing.

I truly appreciate your help in this forum. Thank you for your patience.

Kind Regards,
alagappanK
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9751449
So you are all set then? That is great!!!

I am glad to have helped.

Please close out this question then by accepting the comment that helped you the most as an answer. Also, please close out:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20786536.html

Best of luck with your project,

FtB

0
 

Author Comment

by:alagappanK
ID: 10640798
I solved this question by myself. If you see above, I found the solution.

Please share the points between me and fritz_the_blank.

alagappanK.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10672426
I find this strange--I gave an awful lot of help here, and it seems somewhat ungrateful to request a deletion.

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10672677
I see--I can't help but feel that I answered this question at least a dozen different ways and that any solution that s/he arrived at (perportedly on his/her own) depended upon the information in the thread.

I would have participated here regardless of whether the points were 250 or 500, but there is a lot of time and energy spent here, and I feel that the point reduction reflects a pronounced lack of gratitude for the time volunteered.

However, if after further consideration alagappanK still wants the points back, that's fine, but I would think twice before helping him/her out in the future.

Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10672743
I think that those reviewing the PAQ's would find 9674507 the most useful.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10673195
Thanks Lunchy,

FtB
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now