ASP and JavaScript -

They have: 5,633 posts

Joined: Jan 1970

Can anyone help me out with an ASP /JavaScript question?

I need to code a page so a call to a URL is not hard-coded with a machine name or ISP, but the script HTTP_HOST is substituted instead (so the code in this one file can work on multiple machines). The solution we've come up with here is this line of code

<%=Request.ServerVariables("HTTP_Host")%> replacing the machine name/IP address ie instead of

Link="https://www.site.com

we've substituted
Link="https://<%=Request.ServerVariables("HTTP_Host")%>

The problem seems to be that the <% %> tags around request.serverVariables are interfering with <% %> tags around a larger if/then statement.

This may be too vague to help? My site is internal, so I can't provide a link unfortunately.

John Pollock's picture

He has: 628 posts

Joined: Mar 1999

I haven't ever used ASP myself, so I can't be of much help- but I'm sure someone here has some experience and will be able to help out.

------------------
John Pollock
www.pageresource.com
www.javascriptcity.com

They have: 2,390 posts

Joined: Nov 1998

I know that Chad works with ASP, you can find him in the Hosting Forums.
JP

------------------
The Webmaster Promotion and Resource Site
www.what-next.com
The NEXT step in Designing and Promoting your Website

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

found this while searching for something else.
Easy solution...

original code:

<%
if this = that then
'blah

Link="https://<%=Request.ServerVariables("HTTP_Host")%>

'blah
end if
%>
'
corrected code
<%
if this = that then
'blah

Link="https://" & Request.ServerVariables("HTTP_Host")

'blah
end if
%>
'

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.