Solved

cflocation redirect with image loading

Posted on 2012-03-19
9
327 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now