end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

jsonpだとhttps pageからのhttpによるclient side include(ajax)もOK

scriptタグ内はsame origin policyが無効な為か、jsonpだとhttpsのページからhttpなコンテンツのclient side includeができるようです。

firefox3.6でセキュリティの警告すら、出ないのに驚いた。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<style>
<!--
* {
  margin: 0;
  padding: 0;
  list-style: none;
}
#today {
  border-collapse: collapse;
}
.summary th, .summary td{
  font-weight: normal;
  font-size: x-large;
  border: 5px solid #1E90FF;
  padding: 5px;
}
-->
</style>

</head>
<body>

<table id="local_info">
  <tbody>
  <tr class="summary">
    <th>今日のローカルデータ</th><td id="pow">読込み中</td>
  </tr>
  </tbody>
<table>
<!--★ここでclient side include-->
<script type="text/javascript" src="http://localhost/local_info.js"></script>
</body>
</html>

local_info.js

var local_info = {pow:"500w"};
$("#pow").text(local_info.pow);

ただし、IE8ではセキュリティの警告が表示されます。

先程のscriptはfirefox 3.6では問題なく動作しましたが、IE8の場合、セキュリティの警告が表示されるので、この方法は控えた方が良いのかもしれません。