jQuery リダイレクト

jQuery を使用してページを URL にリダイレクトする方法。

検索エンジンは 301 ステータス コードを使用して、ページ ランクを古い URL から新しい URL に移します。

jQuery リダイレクトが http 応答ステータス コードを返します: 200 OK。

そのため、jQuery リダイレクトは、Javascript リダイレクトと同様に検索エンジンに適していないため、ステータス コード 301 Moved Permanently を返す他のリダイレクト メソッドを使用することをお勧めします。

jQuery リダイレクトは、実際にはJavascript リダイレクトです。 より少ないコードで純粋なJavascript リダイレクトを実行できるため、jQuery を使用したリダイレクトはやり過ぎと見なされます。

jQuery リダイレクト

old page with redirection code をリダイレクト先のページの URL に置き換えます。

古いページ.html:

<!DOCTYPE html>
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<スクリプトの種類="text/javascript">
   // jQuery URL リダイレクト
   $(document).ready( function() {
      url = "http://www.mydomain.com/new-page.html";
      $( location ).attr( "href", url);
   });
</script>
</body>
</html>

jQuery リダイレクトの例

jquery-redirect-test.htm

<!DOCTYPE html>
<html>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
   $(document).ready( function() {
      url = "https://cmtoinchesconvert.com/ja/web/dev/jquery-redirect.htm";
      $(location).attr("href", url);
   });
</script>
</body>
</html>

 

このリンクを押すと、jquery-redirect-test.htm からこのページにリダイレクトされます。

 

jQuery リダイレクト テスト

 

 

Javascript リダイレクト ►

 


こちらもご覧ください

Advertising

ウェブ開発
°• CmtoInchesConvert.com •°