[問題] 一段cross domain的動作看不懂
嗨~
我在學長的系統裡看到一段code,
js
.....
{
var s = document.createElement('script');
s.src = "http://192.168.100.100/index.php";
s.type = "text/javascript";
document.getElementsByTagName('head').appendChild(s);
}
function response_from_server()
{
alert("hi");
}
.....
然後在192.168.100.100這台server的 index.php 裡寫
<?php
echo "response_from_server()";
?>
我的browser domain 是192.168.1.1,當程式呼叫上面那段script後,
會去新創一個<script>的tag,然後去匯入另外一個domain的index.php資料,
而另外一個domain的index.php會直接呼叫browser這端的function並印出"hi"出來。
我的問題是:
因為 script injection算是安全性問題,
這樣的寫法有沒有瀏覽器相容的問題??
其次,為什麼在index.php裡寫個echo function然後在網頁端這邊就可以執行??
再來,假設192.168.100.100這台server不穩或掛掉,
那網頁這邊會嚐試送幾次GET request來要index.php這個資料??
如果server掛掉,那網頁這邊還會一直嘗試跟192.168.100.100要資料嗎??
有懂的人可以回覆嗎?? 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.205.130
→
06/30 22:33, , 1F
06/30 22:33, 1F
→
06/30 22:33, , 2F
06/30 22:33, 2F
→
06/30 23:03, , 3F
06/30 23:03, 3F
推
06/30 23:12, , 4F
06/30 23:12, 4F
→
06/30 23:12, , 5F
06/30 23:12, 5F
→
06/30 23:13, , 6F
06/30 23:13, 6F
→
06/30 23:14, , 7F
06/30 23:14, 7F
→
06/30 23:56, , 8F
06/30 23:56, 8F
→
07/01 01:32, , 9F
07/01 01:32, 9F