相冊裏面的編輯器本身就是引用的遠程圖片。
如何加載遠程圖片:
1.當點擊加載圖片按鈕時,會判斷input輸入框內有沒有值,如果有值的話就將內容以圖片鏈接的方式直接append到div的裏面,當然嚴格的判斷方式應該以正則去匹配
2.js代碼如下:
<meta /ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
if ($("div.content input").val() != '') {
var imgpath = "<img src='";
imgpath += $("div.content input").val() + "' />";
$("div.images").append(imgpath);
}
})
});
</script>
PS:引入MS的cdn,當單擊按鈕時,將input的內容與img標簽拼接壹下,直接append到div裏面,使用jQuery實現。
3.樣式代碼如下:
<style type="text/css">
.content{width:450px;margin:200px auto;padding:20px 100px;border:1px solid green;}
.images{width:300px;margin-top:30px;}
.images img{width:100%;margin-bottom:30px;}
input{width:300px;height:30px;}
button{height:34px;}
</style>
<title>加載遠程圖片</title>
</head>
4..body內容代碼如下:
<body>
<div class="content">
<input type="input" name="image" value="" />
<button>加載遠程圖片</button>
<div class="images">
</div>
</div>
</body>
</html>
輸入框+加載按鈕+圖片區域div