Max
Max

Reputation: 325

Generating HTML Page on the fly

I'm writing a simple html page creator that will generate 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

Upvotes: 0

Views: 2549

Answers (2)

exelotl
exelotl

Reputation: 494

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.

Upvotes: 1

2DH
2DH

Reputation: 1638

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.

Upvotes: 1

Related Questions