簡體   English   中英

如何將我的照片嵌入到其他站點

[英]How to embed my photos to another site

我有一個用於存儲圖像的Spring MVC CRUD應用程序。 我的應用程序將文件存儲在服務器上,並將其地址放入數據庫中,以便我可以訪問它們。 我需要根據選定的圖像創建圖庫,並生成一個embed / iframe代碼,以將該圖庫嵌入到另一個站點。

例如,我可以使用Colorbox創建畫廊,也可以自己編寫畫廊,但是如何生成嵌入代碼?

我已經閱讀了很多有關此的內容,但是沒有找到合適的答案。 我是JavaScript新手,因此需要一些幫助。

為此目的的通用解決方案是一個動態頁面(ASP或PHP或其他動態語言),該頁面生成HTML,但使用Javascript document.write將輸出顯示為javascript文件:

這是ASP的示例代碼:

文件: code.asp

<%
sql="select * from photos order by id desc"
recordset.open sql,objconnection
while not recordset.eof
%>
document.write ('<img src="http://www.example.com/<%=recordset("id")%>.jpg" style="border:0"><br><%=rs("title")%>');
<%
recordset.movenext
wend
recordset.close
%>

由於此文件的輸出為JavaScript的標准格式,因此您可以從<script>標記鏈接至該文件:

<script type="text/javascript" src="http://www.example.com/code.asp"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM