14

I'm looking for a way to embed a Stack Overflow answer into my blog, as I embed my JSfiddle into a blog.

Is there an API to embed Stack Overflow's answers or questions?


Edit: the JSfiddle syntaxe to embed a fiddle is as easy as the single line :

<iframe src="http://jsfiddle.net/F26ur/embedded/result,js,html,css/" 
style="height: 300px; width: 100%;">

StackTack needs 12 lines of code.

14

Just use StackTack, which is the highest upvoted application on StackApps.com. Looks like there's also a WordPress plugin for it (assuming you use WordPress).

Here is a screenshot of it in action:

Screenshot

Edit: Looks like someone in the comments cheesemacfly beat me to it.

| improve this answer | |
  • 1
    What if we no use WordPrez – Cole Johnson Apr 1 '13 at 21:57
  • @ColeJohnson Then use the Javascript thing. I was saying there's also a WordPress plugin for it. – Piccolo Apr 1 '13 at 21:58
  • Whoops. Didn't read fully... – Cole Johnson Apr 1 '13 at 22:00
  • Am I wrong or it needs 12 lines of code ? Not really a shortcut. – Hugolpz Apr 2 '13 at 22:16
  • You are wrong. You already have a head part of your code, may or may not already use jQuery (if you do, you don't need that line), and you already have a <body> All you need to do is add this to your <head>: <script src="http://app.stacktack.com/jquery.stacktack.min.js"></script><script>$(document).ready(function(){$(document).stacktack();});</script> and then add this where you want it: <div id="stacktack-518021"></div> It really isn't that much, and as I said, there is a WordPress plugin for it if that's what you use. The only other way short of writing your own script is an iframe – Piccolo Apr 3 '13 at 2:05
  • @Hugolpz If that's too long for you to embed on a page, then don't embed it. It's the best there is. – Piccolo Apr 3 '13 at 2:07
2

I have created another solution for embedding stack overflow code in websites.

I have wrapped the API with components / directive (not all, but tell me what else you need and I will create it for you, and all the stack overflow community), this is enables you to use it like a tag in your html.

Here is a page that I made to explain it a bit more:

http://weldpad.com/?containerId=59814#/stackover

And here is a live sample: http://weldpad.com/?containerId=47901&editcontainer=61028

In all the samples you can copy the code to your html (or even copy it to notepad and save as html), and just run it, It should work. If not please tell me.

Regards Dan.

| improve this answer | |
  • dead url. Not able to preview or see the content anymore – SheldonH Mar 11 '19 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .