Call an Alert box with ASP

I want to call an alert box with asp with out distrubing the page.
I can do it with the code below but I know that there has to be a better way

<%
Response.Write("some code")
%>
<script language = JavaScript>
      alert('Alert');
</script>
<%
Response.Write("some code")
%>

Let me know if you know of a better way than the above code or just doing a Response.Write("Alert").
quest_capitalAsked:
Who is Participating?
 
davidlars99Commented:
try this

<script language=Javascript>
   setTimeout('alert("Done")', 555)
</script>


or this (IE only)

<script language=Javascript>
   function check(){
       if(document.body.readyState=="complete")
              setTimeout('alert("complete")',555);
       else
              setTimeout('check()', 100);
   }

   check();
</script>
0
 
quest_capitalAuthor Commented:
The code above turns the page white when it gets to the alert box.
0
 
ThaSmartUnoCommented:
what do you mean by not disturbing tha page?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
raj3060Commented:
>>The code above turns the page white when it gets to the alert box.

Reason is that you need to run this on server..

try this:

<%
Response.Write("some code")
%>
<p>I am here.....</p>
<script language = JavaScript>
     alert('Alert');
</script>
<%
Response.Write("some code")
%>
<p>and I am here too.....</p>
0
 
aprestoCommented:
You can use a vbscript pop up when the page loads:

<Script language="vbscript">
msgbox "Alert"
</Script>
0
 
davidlars99Commented:
or mix them up

<script language=Javascript>

   var ie=(navigator.userAgent.toLowerCase().indexOf("msie")!=-1?true:false);

   function check(){
       if(ie)
            if(document.body.readyState=="complete")
                 setTimeout('alert("complete")', 555);
            else
                 setTimeout('check()', 25);
        else
            setTimeout('alert("complete")', 600);
   }

   check();
</script>
0
 
kiddangerCommented:
You cannot have an alert in the middle of an ASP script and have it execute immediately.  All ASP scripting is evaluated and processed before the client gets the code and then the client renders the results.  At that point the alert, would execute, if not in a function, as the page loads.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.