0

Is possible to create and download as .html file using jquery/javascript?

If not, is any third party website API available?

Because I planed to create a prototype maker through in blogger.com.

There I can write only client side program.

2 Answers 2

2

You can try this may help you.

<div id="test">
    <span>testing</span>
</div>

(function(){
    document.location = 
        'data:text/attachment;,' + //here is the trick
        document.getElementById('test').innerHTML;
            //document.documentElement.innerHTML; //To Download Entire Html Source
})();

You can also use html5

<a href="javascript:$('#test').html();" download="Filename">Download Div</a>
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried the $http.get method? That should return a html page (or anything else for that matter). You haven't really said what you want to do with it though...

https://api.jquery.com/jquery.get/

1 Comment

I've just re-read your question - creating a HTML file and uploading it to a server isn't going to be possible without some server side code. Getting an existing file will be possible with the get method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.