-2

Internet Explorer のいずれかの形式を使用している場合、ユーザーが自分の Web サイトを使用できないようにしたいですか? IE を使用している場合、ユーザーを別のページにリダイレクトする php スクリプトを作成するにはどうすればよいですか?

ありがとう

4

2 に答える 2

1

これにより、サーバー側でトリックが行われるはずです。

<?php
    function ae_detect_ie()
    {
        if (isset($_SERVER['HTTP_USER_AGENT']) && 
        (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
            return true;
        else
            return false;
    }

    [...]

    if(ae_detect_ie()) 
        header('Location:/my_IE_webpage.php'); 
?>

ソース: http://www.anyexample.com/programming/php/how_to_detect_internet_explorer_with_php.xml

Javascript を使用してクライアント側で行うこともできます。

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

if(getInternetExplorerVersion() > 0) 
    window.location.href = "/my_IE_webpage.php";

ソース: http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx

編集

またはVulcanのソリューションを使用します (クライアント側も):

<!--[if IE]>
<script type="text/javascript">
    window.location = "http://example.com";
</script>
<![endif]-->
于 2012-09-23T00:22:36.253 に答える
0

PHP よりも JavaScript の方が簡単かもしれません。JavaScript を使用すると、ユーザーが IE を実行している場合にのみスクリプトが実行されるように、スクリプトを IE 条件文で囲むことができます。

<!--[if IE]>
<script type="text/javascript">
    window.location = "http://example.com";
</script>
<![endif]-->
于 2012-09-23T00:27:38.200 に答える