Avatar of atljarman
atljarman

asked on 

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?
JavaScriptjQueryHTML

Avatar of undefined
Last Comment
atljarman
Avatar of Mukesh Yadav
Mukesh Yadav
Flag of India image

Hmmm...
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Blurred text
THIS SOLUTION IS 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
Avatar of atljarman
atljarman

ASKER

Maybe just waiting til page opens, close it, then reopen the same page?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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.
Avatar of bjmurray
bjmurray
Flag of Australia image

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
Avatar of atljarman
atljarman

ASKER

Thanks.  I was thinking Along these lines and will try your suggestion Monday or Monday night.
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo