Jump to content

Stop page loading in IE


kev wood

Recommended Posts

i have built a web based application and have been testing it in firefox and now found that most of the site does not work in IE which is not a big surprise to me but how can i stop the users from loading this in IE.

 

This application will only ever be availble to people who buy it so it will come with a user guide explaining how to download and install firefox and why it should be used over IE but i also want it to direct the user to the firefox download page if they dont already have it.

 

Would it also be possible to write a piece of code that will look to see if they have firefox on there pc already and if so load it in to firefox instead of using IE.

Link to comment
Share on other sites

I think javascript may do it

 

This 'Add to favorites' script knows if it is Firefox or IE

 

<script language="JAVASCRIPT" type="TEXT/JAVASCRIPT">
<!--
function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel("Zortin.com","http://www.zortin.com/",""); }
else { window.external.AddFavorite("http://www.zortin.com/","Zortin.com"); } }
// -->
</script>

 

Cant you trun it somehow

Link to comment
Share on other sites

You can check to see which browser the user is using and give a message to them and redirect.

 

you can use $_SERVER['HTTP_USER_AGENT'] to detect the browser type

 

Here is a function I got from somewhere quite a while ago

 

<?php
function browser_detection( $which_test ) {

// initialize the variables
$browser = '';
$dom_browser = '';

// set to lower case to avoid errors, check to see if http_user_agent is set
$navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';

// run through the main browser possibilities, assign them to the main $browser variable
if (stristr($navigator_user_agent, "opera"))
{
	$browser = 'opera';
	$dom_browser = true;
}

elseif (stristr($navigator_user_agent, "msie 4"))
{
	$browser = 'msie4';
	$dom_browser = false;
}

elseif (stristr($navigator_user_agent, "msie 6"))
{
	$browser = 'msie6';
	$dom_browser = false;
}

elseif (stristr($navigator_user_agent, "msie 7"))
{
	$browser = 'msie7';
	$dom_browser = false;
}

elseif (stristr($navigator_user_agent, "msie"))
{
	$browser = 'msie';
	$dom_browser = true;
}

elseif ((stristr($navigator_user_agent, "konqueror")) || (stristr($navigator_user_agent, "safari")))
{
	$browser = 'safari';
	$dom_browser = true;
}

elseif (stristr($navigator_user_agent, "gecko"))
{
	$browser = 'mozilla';
	$dom_browser = true;
}

elseif (stristr($navigator_user_agent, "mozilla/4"))
{
	$browser = 'ns4';
	$dom_browser = false;
}

else
{
	$dom_browser = false;
	$browser = false;
}

// return the test result you want
if ( $which_test == 'browser' )
{
	return $browser;
}
elseif ( $which_test == 'dom' )
{
	return $dom_browser;
	//  note: $dom_browser is a boolean value, true/false, so you can just test if
	// it's true or not.
}
}

$user_browser = browser_detection("browser");
echo $user_browser."<br />";
?>

 

Ray

Link to comment
Share on other sites

thanks for the reply i found a javascript solution to the problem using the window.location function.  the prob is now as i have not fixed the code yet it is just running through the code and keeps trying to load the page over and over.

 

If the user is in IE it does the redirect fine but if the not it keeps looping around the code and begins to load the page runs the check again and then try to load the page again and again and again.  the page never loads.

 

here is the code incase you want it for future use

 

<script>
if(navigator.userAgent.indexOf("Firefox") != -1)
{
   window.location = "http://www.acmeart.co.uk/mercury/index.php";  //this line is the one making the page keep loading. it is already on this page
}
else
{
   window.location = "http://www.mozilla.org/products/firefox/";
}
</script>

Link to comment
Share on other sites

Problem is, what is some people have javascript disabled?! Using the function above you can do this

 

$browser = browser_detection("browser");
if($browser != "mozilla"){
header('Location:http://somepage.html');
} else {
// run your page below


}
?>

 

Ray

Link to comment
Share on other sites

good point didnt think of that.  well at least the user would have had fun when things didnt work properly in IE because it is sh*t and should be destroyed all together. any enough bout how sh*t IE is

 

so if i use your php function and take this of the end

 

$user_browser = browser_detection("browser");
echo $user_browser."<br />";

 

and replace it with

 

$browser = browser_detection("browser");
if($browser != "mozilla"){
header('Location:http://somepage.html');
} else {
// run your page below


}

 

it will then redirect the user if they are not using firefox.

Link to comment
Share on other sites

So you built an application and failed to:

 

1) Use standard practices that worked in all browsers

 

2) Test it in different environment

 

Thus the conclusion that you draw is that IE is garbage?  I use FF over IE myself but only because I perform web development, otherwise I'd be perfectly happy using IE for basic web browsing.  You're free to distribute your application as you see fit, but intentionally limiting your market is rarely a successful strategy.

 

Problem is, what is some people have javascript disabled?! Using the function above you can do this

Web applications require Javascript to be enabled.

Link to comment
Share on other sites

The application was started by someone else he had set up the application to look how it should then left the company.  I then was given the job of finishing.  As none of the design work was undertaken by me I rather stupidly thought that it would have been tested in all browsers.

 

I have given the application all its functionality and enabled it to do what it does.  it now directs the user to the firefox download page if they are not already using it.  And lets face it if it makes just a few more people start to use firefox it might start to make Microsoft understand that they need some major updating done with IE to bring it up to sprrd with the rest of the browsers and the standards.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.