Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    Malaysia
    Posts
    25

    Thumbs down Unanswered: how to arrange between response.write & response.redirect

    hi friends,

    in my page, after I check the condition, I want to pop up a message and then go to next page. I'm using response.write and response.redirect. But only response.redirect done.

    here is my coding

    Response.Write "<script type='text/javascript'>alert('Terdapat permintaan untuk sokong/lulus cuti.');</script>"
    Response.Redirect("masuk.asp")

    please help....

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    I don't know if this is the answer you're looking for, but you must remember that ASP is processed entirely on the server FIRST... and THEN the html is rendered and sent to the client's browser. This means that you cannot do things like "Alerts" in the middle of an ASP page..... it just doesn't work that way. You need to use something like JavaScript to do that.

    Tim
    Tim

  3. #3
    Join Date
    Apr 2004
    Location
    Malaysia
    Posts
    25
    Thank you for giving me an idea.

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Ok.. you can't do both. Gotta do one or the other. Response.Redirect, if it's in fact doing the redirect (which would be interesting), can usually only be called BEFORE anything is written to the client's browser. Once header information is sent, there's no redirecting. Response.Redirect itself is the response to the browser (such as 200, 404, etc). By sending data to the browser before the response.redirect the browser has to first send a 200 (OK), and now you're stuck, because you can't then send another response to tell the browser to redirect.

    So, now you may be wondering what you can do so solve your delema. Look up META refresh. You can force the browser to do a redirect for you, but I'm about to throw another wrench into the machine. While a JavaScript alert() box is active, the page will not redirect. So you'd have to combine the META refresh, with some javascript that pops open a new browser window with your error message.

    Format of META refresh:
    <META HTTP-EQUIV="refresh" CONTENT="#;URL=<path>">
    # = number of seconds to refresh/redirect after
    <path> = address you want to refresh/redirect the browser to
    That which does not kill me postpones the inevitable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •