开发者

Generating HTML Page on the fly

I'm writing a simple html page creator that will gen开发者_开发知识库erate html code on customized settings. Now i want to add a "Demo" button that will generate a html page on the fly for the user to see the end result.

Is there any way to generate it in an online application?

Thanks


Actually, you don't need to use the server. You can use javascript: urls within Flash to achieve what you want, like so:

var request:URLRequest = new URLRequest("javascript:var w=window.open('', 'FlashGeneratedHTML', 'width=400, height=400'); w.document.write('<html><head></head><body>hello</body></html>');" );
navigateToURL(request, "_self");

All you need to do is replace the HTML code in the document.write() part of the JavaScript code with your own code.


You could do something like that:

var url:String = "http://servlet.url";
var request:URLRequest = new URLRequest(url);
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.html = source.of.your.html;
request.data = variables;
navigateToURL(request, "_blank");

So you basically navigate to some servlet that you have on your server, sending it html that you've created in your Flex app as a POST parameter and opening received responce in the new window/tab. Servlet should send received html back allowing preview of created html to the end user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜