[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 97
  • Last Modified:

Authenticate browser then open page

I have a coldfusion page that needs to have a user authenticated on another application.  Right now the user has to click the link on my page once then the link does not fully function as the user is first logged on.  What I would like to have javascript open the page, verify no 404 or other server error, then reopen the same page.  Is this possible?
0
atljarman
Asked:
atljarman
1 Solution
 
Mukesh YadavFull Stack DeveloperCommented:
Hmmm...
0
 
Dave BaldwinFixer of ProblemsCommented:
I don't think that will work.  A quick search doesn't find any way for javascript to read the HTTP status codes.  A 404 page is just another page to javascript.
0
 
atljarmanAuthor Commented:
Maybe just waiting til page opens, close it, then reopen the same page?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Dave BaldwinFixer of ProblemsCommented:
I don't understand your process but it doesn't sound like javascript will do what you want.  You might as well try it though.  At least then you'll know.
0
 
bjmurrayCommented:
As per previous, im not quite sure what your asking for, but her it goes.

I'm pretty sure it can be done asynchronously using a jquery ajax call

http://api.jquery.com/jquery.ajax/

Scroll down to where is says "statusCode"

For example:
$(document).ready(function() {
	$.ajax({
		type:'GET',
		url: window.location.href, // OR the page you want to check for 404, 500 etc.
		statusCode: {
			500:function() {
				alert('HTTP 500 Error has occurred.');
			},
			404:function() {
				alert('HTTP 404 Error has occurred.');
			},
			200:function() {
				// Everything was ok
				location.reload(); // or redirect to another page
			}
		}
	});
});

Open in new window


I'm not suggesting this a best practice approach or wether or not it will work, but this is a good place to start looking and by all accounts it should be close to a solution.

It also suggests that the same thing could be done with vanilla JavaScript.

Regards
0
 
atljarmanAuthor Commented:
Thanks.  I was thinking Along these lines and will try your suggestion Monday or Monday night.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now