LoginSignup
3
6

More than 5 years have passed since last update.

Ajaxで取得したHTMLからタイトルを取得する方法

Last updated at Posted at 2016-10-27

他のページのHTMLを取得する方法

クロスドメインで他のページを取得する方法

> Ajaxで取得したHTMLからタイトルを取得する方法

index.html

<!DOCTYPE html>
<html lang="ja">
    <head>
        <meta charset="utf-8">
        <title>Get A Other Page</title>
    </head>
    <body>
        <script src="js/jquery.js"></script>
        <script src="index.js"></script>
    </body>
</html>

index.js

$.ajax({
    type: 'GET',
    url: 'http://localhost/',
    success: function(data) {
       var t = data.match(/<title>(.*)<\/title>/);
        console.log(t[1]);
    }
});

取得したタイトル

Taiyaki Web
3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6