...

View Full Version : Versus using the alert



jwindon
01-11-2004, 05:54 AM
Is there another command I could use other than.....

alert("Thank You for your information.");

....something that doesn't sound the same as the error message?

Philip M
01-11-2004, 08:50 AM
If the message is to appear after the user has completed and submitted a form then you can redirect to a "thank you" page,
or you could make a pop-up window with a suitable message.

An example:-

<SCRIPT type="text/javascript">
<!--
function makemessage(page) {
OpenWin = this.open page, "CtrlWindow","top=80, left=100,width=250,height=100, toolbar=no,menubar=no, location=no,scrollbars=no,resizable=yes");
}

function closepop(){
if (OpenWin != null) OpenWin.close();
}

window.onunload=closepop;

// -->
</SCRIPT>



Then

onclick="makemessage('TheMessageFile.html'); return false"

onclick can be replaced by some other event handler of course, such as onsubmit.

and TheMessageFile.html contains whatever message you want to display.

jwindon
01-11-2004, 06:59 PM
Thanks for the reply Phillip.

I tinkered with the code a bit.

I was looking for a way to have a message come up that did not require a separate html file. That's why I was looking into alert.

Currently, I do have a redirect to a thank you page.

jwindon
01-11-2004, 07:48 PM
I put this code in:

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);

}

It is called from inside of another function.

What do I need to do to automatically close the pop-up window after a set period of time. Is there an statement that is put in the 'features' argument?

Dennis
01-11-2004, 08:15 PM
try something like this...

<script>
function MM_openBrWindow(theURL,winName,features) { //v2.0
win=window.open(theURL,winName,features);
window.setTimeout('win.close()',5000)
}
</Script>



the popup should close after 5 sec

jwindon
01-11-2004, 09:32 PM
Thanks Dennis.

Think I found my answer here (http://www.codingforums.com/showthread.php?s=&threadid=31295) as posted in reply by jujuraf.

function DoSomething()
{
var outW = window.open("", "newwin", "top=250, left=250, height=150, width=300");
outW.document.write("<HTML>")
outW.document.write("<TITLE>Confirmation</TITLE>");
outW.document.write("<font color=#0000CC>");
outW.document.write("<div align=center><strong>Thank You");
outW.document.write("<P>Your Information has been received.</P></strong>");
outW.document.write("<div align=center>");
outW.document.write("<input type=button name=button value=OK>");
outW.document.write("</div>");
outW.document.write("</HTML>");
outW= window.setTimeout(outW.close(), 2000);
}

Windows closes, but right away and then I get 'Error on Page'.

:confused:

Willy Duitt
01-12-2004, 12:18 AM
Try removing:
outW= window.setTimeout(outW.close(), 2000);

And replace with:
onblur=self.close()
and add a body tag to your popup.
outW.document.write("<body onload=self.focus()");


If your redirect to the thank you page is called at the same time this popuup is called. The popup will close when the thank you page recieves focus

....Willy

jwindon
01-12-2004, 12:33 AM
If I put it like that.......the page that creates the pop-up closes. :(

The DoSomething function is called before the submit function executes and sends to a rediret location.

I'm attempting to have a pop up (created with this 'write' method) that says basically..thank you....and then closes after a few seconds. The user should be left staring at the redirect location.

function DoSomething()
{
var outW = window.open("", "newwin", "top=250, left=250, height=150, width=300");
outW.document.write("<HTML>")
outW.document.write("<TITLE>Confirmation</TITLE>");
outW.document.write("<body onload=self.focus()");
outW.document.write("<font color=#0000CC>");
outW.document.write("<div align=center><strong>Thank You");
outW.document.write("<P>Your Information has been received.</P></strong></div></font>");
outW.document.write("</HTML>");
onBlur=self.close();
}

Willy Duitt
01-12-2004, 01:47 AM
The DoSomething function is called before the submit function executes and sends to a rediret location.

Why would you have your "Your Information has been recieved" popup fire before the form is even submitted?

It should be: Submit --> popup --> location.replace="redirectLoction.html"

BTW: Don't you need to close your body tag?
outW.document.write("<body onload=self.focus()");

jwindon
01-12-2004, 01:55 AM
Willy:

Well you caught me on the submit after the pop up. I fixed that. Had already found my syntax typo on the body tag. Still, after searching the forums and internet all afternoon, I'm at a loss as to how to close my pop up (which is not an html file that would be on the server as you see by the write method). So I've elected to give it up and let the user close that pop up themselves. I got close a couple times, but each time, it closed the page the DoSomething was called from versus the page the DoSomething function creates.

This is where I left it.

function DoSomething()
{
var outW = window.open("", "newwin", "top=250, left=250, height=150, width=300");

outW.document.write("<HTML>")
outW.document.write("<TITLE>Success</TITLE>");
outW.document.write("<body>");
outW.document.write("<font color=#0000CC>");
outW.document.write("<div align=center><strong>Thank You");
outW.document.write("<P>Your information has been received.</P></strong></div></font>");
outW.document.write("</body></HTML>");
//window.setTimeout('self.close()',7000);
}


called from:

function validation(){
if(.........
}
else {
document.REG.submit();
DoSomething();
return true;
}
}

Willy Duitt
01-12-2004, 02:05 AM
If you use the onblur="self.close()" in the popup and set focus to your redirect page when it loads, the popup will lose focus and close itself when the focus shifts.

But, you should also provide a close button on the popup anyway.

jwindon
01-12-2004, 02:09 AM
Thanks Willy.

I'm burned up with this for now. I have another collection to do right after this one...so maybe I can get it straight for that one. I tried your code, but I'm obviously doing something very wrong. I've attached the full page if you are interested in showing me the correction. If not; thanks for the guidance and I'll try again on the next project.

:cool:

Willy Duitt
01-12-2004, 03:48 AM
I downloaded the file and will take a look at it later when I feel better. I have a migraine right now which is killing me. :(

.....Willy

jwindon
01-12-2004, 03:50 AM
Sorry to hear that Willy:(

Hope you feel better.

(I do....with this much done)

On to the next collection:rolleyes:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum