Go to a web page automatically
Jim Ault
jimaultwins at yahoo.com
Sat Jul 10 22:03:05 EDT 2010
On Jul 10, 2010, at 5:56 PM, Sarah Reichelt wrote:
> On Sun, Jul 11, 2010 at 10:20 AM, Tim Selander
> <selander at tkf.att.ne.jp> wrote:
>>
>> Thanks for the reply. Sorry for not being clear. By 'open' I mean I
>> just
>> want to take the user to another page, as if they had clicked a link.
>>
>> I'm trying to write a simple form to get user input (based on Sarah's
>> revForm.irev script) and want to take them to a 'Thank you' page
>> automatically after they submit the info.
>
> I found that the easiest way was to show or hide info on the same
> page, depending on user input.
>
> But if you want to take them to a different page, you can redirect.
> Check out the script
> http://www.troz.net/onrev/samples/showscript.irev?showscript=desktop.irev
>
> Note that the redirect headers have to be "put" BEFORE anything else
> is written to the page.
>
> Sarah
For web content serving,
there are actually 3 different things being specified in this thread.
UPDATING THE SAME PAGE, REDIRECT, LOCATION
I think the bottom of this post has the answer you probably want to use.
UPDATING THE SAME PAGE - sending HTML tags and content to be displayed
in the current browser window
If the user does 'reload' or 'refresh', the original content will be
re-displayed since the browser still thinks it is focused on the
original url.
The new content does not change the browser history since there has
been no real navigation as far as the browser is concerned.
> <?rev
> get url "http://www.runrev.com"
> put it
> ?>
REDIRECT - tells the browser to keep the current url in history, but
now focus on a new url
This is commonly used to keep old links stored out on the internet
working, but 'bounce' to new web pages or url.
This gets a little complicated when you break down the different
meanings of a url.
http://someDomain.com/ or http://www.someDomain.com/ or http://someDomain.com/index.html
-- will simply show the default page for the domain
http://someDomain.com/aboutus.html or
http://someDomain.com/aboutus.php or
http://someDomain.com/aboutus.cgi or
http://someDomain.com/aboutus.irev
-- will simply show the page for that location
http://someDomain.com/aboutus.html#drivingMapSection
http://someDomain.com/aboutus.php#drivingMapSection
http://someDomain.com/aboutus.cgii#drivingMapSection
http://someDomain.com/aboutus.irev#drivingMapSection
-- will show the page and scroll to the anchor named
http://someDomain.com/aboutus.html?loc=homeOffice xx no
http://someDomain.com/aboutus.php?loc=homeOffice
http://someDomain.com/aboutus.cgi?loc=homeOffice
http://someDomain.com/aboutus.irev?loc=homeOffice
-- will show the page with info that a script provides by using the
variable 'loc' with the value "homeOffice"
The exact data sent back to the browser depends on the script
programming
NOTE: PHP and irev and cgi cause scripts to run on the server, but
HTML does not, so sending variables.
The reason scripts are run is that Apache has been told when it
started that those 3 strings mean that Apache should follow its
directives and run the correct script engine. At this time, the only
server that knows about irev is the On-Rev system, thus irev scripts
cannot be run on other systems.
The On-Rev server knows how to run scripts using PHP, cgi, as well as
irev.
LOCATION - This is probably what you were looking for
- change the Browser's memory variable that causes the browser to
focus on the new url, keeping the original url in history, and
reloading the new url.
What you probably want to accomplish is sending a raw HTTP header to
the browser.
More details here [ http://php.net/manual/en/function.header.php
Possible headers to send to a browser
Their are two kinds,
Request (from browser) to instruct the Apache server
Accept-Language: da
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Response (from server) to instruct the browser
Content-Type: text/html; charset=utf-8
Location: http://www.w3.org/pub/WWW/People.html
Refresh: 5; url=http://www.w3.org/pub/WWW/People.html
(refresh the same url after 5 seconds)
Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
(store data on the user's hard drive)
(but it expires in 3600 seconds, 60 minutes)
http://en.wikipedia.org/wiki/List_of_HTTP_headers
and specifically HTTP_location discussed here
http://en.wikipedia.org/wiki/HTTP_location
so in irev you would
--***********
<?rev
put "HTTP/1.1 302 Found" into sendResponse
put cr & "Location: http://www.www.runrev.com" after sendResponse
put sendResponse -- back to browser that started the dialog
?>
--***********
Just to let you know, REDIRECTION issues are much more complex
This is a good overview...
http://en.wikipedia.org/wiki/URL_redirection
Bottom line for your specific task, use the scripting just below the
"*****"
Hope this helps. You have chosen to enter a world that can be very
confusing, so tread carefully and study tons of examples.
Jim Ault
Las Vegas
More information about the use-livecode
mailing list