简体   繁体   English

如何将我的照片嵌入到其他站点

[英]How to embed my photos to another site

I have a Spring MVC CRUD app for storing images. 我有一个用于存储图像的Spring MVC CRUD应用程序。 My app stores the files on the server and puts their addresses into database, so I can access them. 我的应用程序将文件存储在服务器上,并将其地址放入数据库中,以便我可以访问它们。 I need to create a gallery from selected images and generate an embed/iframe code to embed this gallery to another site. 我需要根据选定的图像创建图库,并生成一个embed / iframe代码,以将该图库嵌入到另一个站点。

I can create a gallery, for example, with Colorbox or write it by myself, but how should I generate the embed code? 例如,我可以使用Colorbox创建画廊,也可以自己编写画廊,但是如何生成嵌入代码?

I've read a lot stuff about this, but didn't find the appropriate answer. 我已经阅读了很多有关此的内容,但是没有找到合适的答案。 I'm new to JavaScript so I need some help. 我是JavaScript新手,因此需要一些帮助。

The general solution for this purpose is a dynamic page (ASP or PHP or other dynamic languages) which generates HTML but using Javascript document.write to present the output as a javascript file: 为此目的的通用解决方案是一个动态页面(ASP或PHP或其他动态语言),该页面生成HTML,但使用Javascript document.write将输出显示为javascript文件:

This is a sample code by ASP: 这是ASP的示例代码:

File: code.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
%>

As the output of this file is in standard format of JavaScript,So you can link to it from a <script> tag: 由于此文件的输出为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