Solved

cflocation redirect with image loading

Posted on 2012-03-19
9
329 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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 500 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
On Submit return to same spot 7 101
Detect and combat possible robot 7 119
Coldfusion Mysql get data from two tables 3 102
coldfusion, jQuery help 25 111
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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