Avatar of nirsait
nirsait
 asked on

cflocation redirect with image loading

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.
ColdFusion Language

Avatar of undefined
Last Comment
_agx_

8/22/2022 - Mon
SidFishes

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.
nirsait

ASKER
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.
SidFishes

"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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
nirsait

ASKER
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.
_agx_

(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.
ASKER CERTIFIED SOLUTION
SidFishes

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nirsait

ASKER
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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
nirsait

ASKER
This got me to looking for an answer.
_agx_

<meta content="3;

Why delay the redirect even more?