🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.javascript
1 messages
1 total messages Started by Russ Moore Sat, 27 Feb 1999 00:00
Problem: Frames, Mac and NN
#214
Author: Russ Moore
Date: Sat, 27 Feb 1999 00:00
114 lines
4902 bytes
Much appreciation and deep gratitude to any hints towards solving this
problem.

I've modified some code to allow the re-direction of a standard reply
from an ISP provided CGI form program and replacement with personal
confirmation or failure pages. It uses a typical hidden frame approach.
The frameset page holds the JavaScript and the visible frame has the
form page and the hidden frame is preloaded with a dummy page with the
title 'Blank Title' (original huh :} ) When the form is submitted the
JavaScript , see below, compares the title of the document in the hidden
frame until it changes from the preset. When this happens it checks for
a number of known features of the standard reply and then redirects to
the user's confirm or failure page, destroying the frameset as it does
so.

It works on a PC with both IE3 IE4 and NN 4.06, and on the Mac with IE4.
It even degrades with Lynx and is not even a total disaster with WebTv.
However with NN 4.08 on the Mac it just refuses to behave. It
consistently just goes straight to the failure page after the form is
submitted.

I think I can safely rule out a frame not having finished loading. The
re-load bug caused by META tags is unlikely as this would occur across
all browsers not just the one. As all pages are created in the same
domain there shouldn't be any security problem. Which seems to leave
pure b.. mindedness; or do you now different.

Russ

CODE EXTRACT
var blankTitle = "Blank Frame";
var FileSent = false;
function formHandler()
{
        clearTimeout(timerID); // Clear timer
        // place marker for validation routine
        WaitForReply(); // Wait for reply from www server
        if(demo || FileSent)
        {
                FileSent = true;
                return( false);
        }
        else
        {
                FileSent = true;
                return( true);
        }
}
// Wait for a reply from Demon. Check for reply once per second.
// Load the users confirm page if the Demon reply is okay.
// Otherwise load a page indicating a failed form submission.
//
function WaitForReply()
{
        if (ReplyReceived())
        {
                if (FormSubmitted())
                {
                        // Loads your custom form confirm page,telling
it where to return
                        // replaces this document so to removes the
framset created by the loader
                        self.location.href = ConfirmPage + '?' +
CallingPage;
                }
                else
                {
                        // Load your custom form failure page with same
info
                        self.location.href = FailurePage + '?' +
CallingPage;
                }
        }
 else
        {
                timerID = self.setTimeout("WaitForReply()",1000);
        }
}
// Returns true if frame 'receive' contains a page other than
blankFrame.
// This occurs when Demon mailform script sends a reply.
// The reply may be a confirmation page or an error message.
//
function ReplyReceived()
{
        return (window.receive.document.title != blankTitle);
}
// Returns true if 'receive' contains the Demon mailform confirmation
page.
//
function FormSubmitted()
{
        var CorrectTitle = (window.receive.document.title ==
ReplyTitle);
        if (demo)
        {
                var CorrectPath = true;
                var CorrectHost = true;
        }
        else
        {
                var CorrectPath = (window.receive.location.pathname ==
ReplyPath);
                var CorrectHost = (window.receive.location.hostname ==
ReplyHost);
        }
 return (CorrectTitle && CorrectPath && CorrectHost);
}


-- ----------------------------------------------------------------------------
|< mailto:RussM@verge.demon.co.uk >           Live NOW and pay later          |
|< http://www.verge.demon.co.uk/index.htm  Life's too short to take seriously |
-------------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads