作者phenombox (锁尼)
看板Web_Design
标题[问题] 载入html档到网页内
时间Thu May 29 22:23:37 2014
A网页是欲载入的网页
B网页是我目前做的网页
请问要如何将html档透过<input type="file">选取档案的方式
将一个A网页(html)的内容载入B网页内容呢
我原本用
<input id="file" type="file" name="file" onClick="myFunction()" />
<br />
<button onclick="loadAction()">载入</button>
<script>
var x
function myFunction()
{
x = document.getElementById("file");
}
function loadAction()
{
alert(x.value);
$('#page2').load(x.value,function(response) {$('#page2').text(response); });
$('#page').load(x.value);
}
</script>
jQuery的load後面如果打上路径可以读取档案,
不过用input的方式,将选取的档案以x表示
可以再alert看到x.value,也就是绝对位子的路径
但是贴到load怎麽样都读不到,请问各位可以怎解决呢?
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 163.17.133.110
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Web_Design/M.1401373419.A.1BA.html
※ 编辑: phenombox (163.17.133.110), 05/29/2014 22:25:50
1F:→ alog:security 层面的问题 05/29 22:25
2F:→ banjmin:CROS的问题 server side要写Access-Control-Allow-Origin 05/29 22:26
3F:→ banjmin:的header 05/29 22:26
请问大大,我的网页和被载入的网页都是在同一台电脑,可是我有用xampp把我的网页放在
htdoc内没用到php,依然会有安全性的问题吗?谢谢
※ 编辑: phenombox (163.17.133.110), 05/29/2014 22:27:32
※ 编辑: phenombox (163.17.133.110), 05/30/2014 10:21:17
4F:推 alog:browser对於input物件权限给很低 不可能直接读取本机的内容 05/30 11:14
5F:→ alog:否则骇客可以透过类似方式来读取电脑的内容 05/30 11:15
了解了,谢谢您:)
※ 编辑: phenombox (163.17.133.110), 05/30/2014 11:51:37
6F:推 gtr99:变通一下先做非同步上传再load回来 05/31 02:22
7F:→ mmis1000:html5 的 filesystem好像能做到 05/31 02:29