Prevent errors on iFramed pages with JavaScript

Related resources from SearchDomino.com:
Access form fields in iFrame through Javascript when clicking an event outside iFrame

FAQ: Lotus Notes, Domino and JavaScript

JavaScript Reference Center

After deleting an iFramed page, unsightly errors can occur. Similar errors also occur if the Lotus Notes Domino user doesn't have access to the iFramed page. The following JavaScript code can be used to avoid such errors.

Using the httpRequest object, check the page header to trap the page status. If Domino serves iFramed pages, you can easily support custom applications status codes, if needed.

//helper function
function reGetUrlParameter( name , url ){
//from http://www.netlobo.com
name = name.replace(/[[]/,"\[").
var regexS = "[\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( url );
if( results == null ){
return "";
return results[1];

//get the httpRequest object
function getHttprequestObject(){
//from http://www.w3schools.com
var mime = 'text/xml'; 
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}else if(window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

//check the iframed page and present 
something nice if it is not available function checkUrl(){
var params = xmlhttp.getResponseHeader("Set-Cookie");
//these params can be set in a computed for 
display field; use @SetHTTPHeader
var releasestatus = reGetUrlParameter
("someparamfromdoc", params); 
var pagestatus = xmlhttp.status;
if( pagestatus==200 ){
if( someparamfromdoc=="wrongstate" ){
stattxt = "Iframed page has wrong internal state."
}else if( pagestatus==401 ){
stattxt = "Iframed page is not accessable with
 your current access right."
}else if( pagestatus==404){
stattxt = "Iframed page has been deleted."
 if(stattxt != ""){ iframeHtml = stattxt }
 document.write( iframeHtml );

//just give the url to this function
function startUrlCheck(testUrl){
xmlhttp.open("HEAD", testUrl, false);
xmlhttp.onreadystatechange = function(){
 if (xmlhttp.readyState==4){


Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Steen Grunds. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was first published in April 2008

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.