Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a function with asp

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hey there,

how can you call a javascript-function with asp?

e.g.

<script language=&quot;javascript&quot;>
function message()
{
alert(&quot;this message&quot;)
}
</script>

and then you have
<% ... %>

how can I call the message function within the <% ... %>?
 
you can use your server script to actually write out an inline javascript statement that would call the function such as:

<%response.write(&quot;<script language=javascript>message();</script>&quot;)%>

:)
Paul Prewett
 
Hey, oké thanx but maybe I wasn't realy clear ...

the problem is:

I have to show a message before I Redirect ... like this:

<% Response.Write (&quot;<script language='javascript'>message();</script>&quot;) %>
<% Response.Redirect &quot;test.asp&quot;%>

because I use Redirect I have:
<% @ language = &quot;vbscript&quot;%>
<% Response.Buffer = true %>
in the top of my page but then he doesn't show me the messagebox
 
yea -- another member was having this problem last week or something. Here's why it doesn't show the message box:

All server side code is interpreted BEFORE any client side code, which means that even though the line is encountered first, it writes client side code, which will not execute until all the server side code is done -- and you will be redirected by then --

Best bet will be to use client side redirection to achieve the wanted results -- you can just write the code like this:

<%response.write(&quot;location='&quot; & &quot;yourPage.asp&quot; & &quot;';&quot;)%>

rather than:
<%response.redirect(&quot;yourPage.asp&quot;)%>

and put your function call (message()) directly before it so that you get your message, and then get your redirect.

hope it helps! :)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top