Solved

cflocation redirect with image loading

Posted on 2012-03-19
9
324 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

20 Experts available now in Live!

Get 1:1 Help Now