2 Replies - 231 Views - Last Post: 16 August 2017 - 01:43 PM

#1 dday9  Icon User is offline

  • D.I.C Regular

Reputation: 94
  • View blog
  • Posts: 495
  • Joined: 17-April 13

Only Display Element in IFrame

Posted 16 August 2017 - 11:03 AM

I often will provide code examples using dotnetfiddle.net and I'm wanting to include an iframe on my website that displays the code from the shared fiddle. The particular element that I want to display has an id of Console, but I'm not exactly sure how to display just that element and not the entire webpage.

For example, I've attempted:
<iframe src="https://dotnetfiddle.net/IwGhDN #Console"></iframe>


And I've also tried a JQuery solution:
$(document).ready(function(){
    $("iframe").bind("load",function(){
        $(this).load($(this).contents().find("#Console").html());
    });
});


But neither of the two work.

Is This A Good Question/Topic? 0
  • +

Replies To: Only Display Element in IFrame

#2 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6375
  • View blog
  • Posts: 25,756
  • Joined: 12-December 12

Re: Only Display Element in IFrame

Posted 16 August 2017 - 12:59 PM

dotnetfiddle already offers a share, embed in iframe, feature which seems to work on a brief look. It even offers an advanced widget builder.

Otherwise, I doubt that we will be encouraging an attempt to remove the cruft from such a resource. In any case, there are plenty of ways to display pretty code on your website, and you might then include, additionally, a link to the dotnetfiddle code.

(The space doesn't help.)
Was This Post Helpful? 1
  • +
  • -

#3 dday9  Icon User is offline

  • D.I.C Regular

Reputation: 94
  • View blog
  • Posts: 495
  • Joined: 17-April 13

Re: Only Display Element in IFrame

Posted 16 August 2017 - 01:43 PM

I feel a little silly that I didn't notice the iframe option in DotNetFiddle's share.

None-the-less, the prettify javascript plugins are good, but the dotnetfiddle will display intellisense things.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1