简体   繁体   中英

How to embed my photos to another site

I have a Spring MVC CRUD app for storing images. 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.

I can create a gallery, for example, with Colorbox or write it by myself, but how should I generate the embed code?

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.

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:

This is a sample code by ASP:

File: 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM