• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

onLoad redirect

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

We have our home page which we have restricted only to IE and we have displayed the same message in our home page.However when it is run on other browsers the home page is getting loaded.
In index.jsp (home page) I have written a browserCheck function ...

function browserCheck(){
//alert("hai");
var browserName = navigator.appName;
if(browserName == 'Microsoft Internet Explorer')
return true;
else{
//alert("in else");
var url=null;
//url = 'browserCheck.action';
var urlData= '<ptms:url value="/browserCheck.action"/>';
//alert(urlData);
processAjax(urlData,test,false,null);
return false;
}
//return false;
}


this is processAjax function ...
------------------------------------
function processAjax(url, callbackFun, async, args){
var xmlhttp = null;
if (xmlhttp != null && xmlhttp.readyState != 0 && xmlhttp.readyState != 4){
xmlhttp.abort();
return;
}

if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else if (window.ActiveXObject){
try{
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
}

if (xmlhttp != null){
xmlhttp.open('post',url, async);
//xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');
//xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
var data = xmlhttp.responseText;
callbackFun(data,args);
}else{
alert('Problem retrieving data : ' + xmlhttp.statusText);
}
}
}
xmlhttp.send(null);
}else{
alert('Your browser does not support xmlhttp.')
}
}


currently it is displaying the home page rather than returning false...

Ideally I want to direct to a page(browserTest.jsp) saying " please use IE only" (something on these lines) before the page loads.

Due to paucity of time(EOD) I don't think before load prevent would be feasible...... I am thinking of following options..

1) onLoad of homepage in other browsers ,Highlight the message " This ..... to be viewed in IE only" (increase font size etc)
2) put a glamorous dialog box(best popup or some style possible ) saying " please use IE only"


need inputs.thankyou!

Regards,
Pradeep
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want you can check for the browser in the action only and return the error page from there rather than from the page itself. This will make you code much neat and you don't have to worry any more for the error.
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pradeep,

1. Please use code tags
2. Check if "navigator.appName" works fine in all browser
3. Has Jinal mentioned use server side code and a global error page instead of JavaScript, what if the client browser java script is diabled?
reply
    Bookmark Topic Watch Topic
  • New Topic