如何保存用户创建的HTML页面? [英] How to save a user made HTML page?

查看:120
本文介绍了如何保存用户创建的HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个拖放实用程序,使用户可以直接在工作场所拖放元素并创建页面,我伤口该如何将用户的工作保存为HTML页面!

I made a drag and drop utility that make it possible for users to drag and drop elements directly on a workplace and create their page, I wound how can I save the user's work as HTML page!

推荐答案

你是指所有元素的位置?如何迭代他们并保存他们的位置?如果你使用jQuery,你可以这样做:

You mean the position of all elements? How about iterating through them and saving their position? If you use jQuery you could do something like this:

var positions = new Array();
function savePositionOfAllDivs() {
 $('div').each( function(){
  $this = $(this);
  id = $this.attr('id');
  position = $this.position();
  left = position.left;
  top = position.top;
  positions[id] = new Array();
  positions[id]['left'] = left;
  positions[id]['top'] = top;
 }
}

然后将位置数组发送到某个服务器端脚本,将其转换为CSS,然后将其嵌入用户的HTML页面可以下载。

And then send the positions array to some server side script which turns it into CSS which you can then embed into the HTML page that the user can download.

(关于你想要做什么的更多细节信息可能会更加简单和有效,假设它是一种拖放功能,那么你只需要保存div的顺序)

(With more specefic information about what your trying to do this could be way more easy and effecient. Say it is a order drag 'n drop functionality then you only have to save the order of div s)

这篇关于如何保存用户创建的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆