[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

cflocation redirect with image loading

Posted on 2012-03-19
9
Medium Priority
?
343 Views
Last Modified: 2012-06-22
I am trying to get a ColdFusion page to display a 'loading...' screen until the page gets redirected to another site.

If I just use this code:

<cfif isdefined("client.ID") and trim(client.ID) gt "">
	<cflocation url="/testing/SVSSOWeb1.asp?MemberID=#client.ID#" addtoken="no">
</cfif>

Open in new window


The page will sit pretty blank until it eventually reloads. I want to have some sort of "loading" appear until the page redirects properly.

I tried this code, which does the proper "Loading..." part but it then never redirects:

<br><br><center>

<span id="loading">
<img src="ajax-loader.gif" alt="please wait"> ... Loading ...
</span>

<cfif isdefined("client.ID") and trim(client.ID) gt "">
	<cflocation url="/testing/SVSSOWeb1.asp?MemberID=#client.ID#" addtoken="no">
</cfif>

Open in new window



Can someone please help combine these two so I can have a "loading" page until the page redirects?

Thank you in advance.
0
Comment
Question by:nirsait
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 36

Expert Comment

by:SidFishes
ID: 37739088
You can't really do it with cflocation. That does a 302 redirect and as soon as the client browser gets the header it moves to the redirect location without processing any more on the page.

something like this may be what you are looking for

<span id="loading">
<img src="ajax-loader.gif" alt="please wait"> ... Loading ...
</span>

<META HTTP-EQUIV=Refresh CONTENT="0; URL=http://yoursite/testing/SVSSOWeb1.asp?MemberID=#client.ID#">

 but I don't really understand the need. Once you've kicked off a new page load, the browser focus should go to the new page. It's what people expect.
0
 

Author Comment

by:nirsait
ID: 37739192
Thank you for the update.

Actually I would 'think' it should just do a quick page load to the 'redirect' URL. However, it usually sits as it waits to find a load the other page. Hence the reason for wanting som sort of page 'loading' until is actually does a redirect.

Using the META version of the redirect, looses any information in the #client.ID# area so it kicks back an error with the 'MemberID='

So this is still not working properly.

Thank you.
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 37739255
"looses any information in the #client.ID# area"

No reason it should do that. Do you have the tag surrounded by <cfoutput>?


"sort of page 'loading' until is actually does a redirect."

The thing is that with the meta content set to 0, the redirect happens -immediately-. Replace the url with google.com - you probably won't even see the loading image.

I think what you're talking about is page load time  - which is a different thing entirely.

You could try to "preload" the page while showing the Loading graphic. There are ideas here http://stackoverflow.com/questions/3275056/preloading-of-html-web-page-or-non-flash-web-applications 

I'd look at the jQuery suggestion from Robert
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:nirsait
ID: 37739419
No, I do not have the tag surrounded by <cfoutput>. The information being sent is:

<cfif isdefined("client.ID") and trim(client.ID) gt "">
      <cflocation url="/testing/SVSSOWeb1.asp?MemberID=#client.ID#" addtoken="no">
</cfif>

Then from the receiving ASP page I am pulling the information in as:

MemberID = Request.querystring("MemberID")

Using the META version, it is not picking up any #client.ID# information.

I am trying to wrap a 'Page Loading' concept around this <cfif>...<cflocation>... concept since the page actually takes a bit load and redirect. so if there is any other way to do that it would be great. If not, then the page will just load slowly until it redirects.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37739483
(no points ...)

Using the META version, it is not picking up any #client.ID# information.

You need cfoutput tags.  It's because META isn't a CF tag so the #client.ID# variable won't be evaluated unless you include them.

<cfif isdefined("client.ID") and trim(client.ID) gt "">

What do you want to happen if neither of those is true? I assume you're anticipating/handling that scenario.
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 1500 total points
ID: 37739539
if #client.ID# is not surrounded by cfoutput all you are sending in the url is a literal string #client.ID# so your asp will be parsing

memberId = #client.ID#

instead of

memberID = 5423234231 or whatever

"If not, then the page will just load slowly until it redirects." no that's not correct. The redirect happens immediately.

The flow is redirect > page load. Once you've done a redirect of any kind, the browser is no longer interested in anything that's on the pre-redirect page. the fact that there still is something visible is arbitrary and probably browser specific.

Bottom line - If the target page is slow to load, a loading indicator on the calling page isn't going to help unless you try the preload scheme or maybe something with an iframe. Neither are great solutions.
0
 

Author Comment

by:nirsait
ID: 37739638
Here is what I ended up using that worked:

<cfparam name="URL.redirect" default="/testing/SVSSOWeb1.asp?MemberID=#client.ID#">

<html>

<head>
<title>Loading...</title>
<script language="JavaScript">
if(document.images) image1 = new Image(); image1.src = 'ajax-loader.gif';
</script>
<cfoutput><meta http-equiv="refresh" content="3;url=#URL.redirect#"></cfoutput>
</head>

<body style="background-image: url(ajax-loader.gif); background-repeat: no-repeat; background-position: 50% 50%;">

<br>
<br>
<br>

</body>

</html>

Open in new window


Thanks.
0
 

Author Closing Comment

by:nirsait
ID: 37739649
This got me to looking for an answer.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 37739728
<meta content="3;

Why delay the redirect even more?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question