0

I need to load an external webpage into a div. I don't want to use an iFrame. And I want this done with plain Javascript or Jquery. I'm not sure how to go about it.

Chan
  • 61
  • 1
  • 13
  • 1
    Better can use ajax function check it out – I'm Geeker Mar 06 '15 at 07:02
  • @Chanukya Varma use $.load function in jquery. http://api.jquery.com/load/ – Frebin Francis Mar 06 '15 at 07:03
  • [Ajax/jQuery - Load webpage content into a div on page load?](http://stackoverflow.com/questions/9963799/ajax-jquery-load-webpage-content-into-a-div-on-page-load) – tsh Mar 06 '15 at 07:04
  • Actually I have embed code of my site ,if i copy embed code and i paste it into another site it is working with iframe but i want this happen using pure javascript or jquery not with iframe – Chan Mar 06 '15 at 07:12
  • I have used my embed code like this
    but it is not loading the page
    – Chan Mar 06 '15 at 09:59

3 Answers3

0
$( "#DIVID" ).load( "Path" );

it will load your html data into any div.

ABIRAMAN
  • 929
  • 8
  • 12
  • I have used my embed code like this
    but it is not loading the page
    – Chan Mar 06 '15 at 10:11
  • You can't load page out of Your project until the owner of that webpage enabled 'CROSS SCRIPTING' in his page. – ABIRAMAN Mar 06 '15 at 12:06
0

There are many ways, here are a couple:


.load()

References

http://www.w3schools.com/jquery/jquery_ajax_load.asp

http://api.jquery.com/load/

Example

$( "#result" ).load( "ajax/test.html" );

jQuery.ajax()

References

http://api.jquery.com/jquery.ajax/

Example

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});
HandyDan
  • 425
  • 2
  • 8
0

This problem is easily solved using <jsp:include> tag. But I wouldn't like to recommend. It just attach another JSP file to template.

template.jsp

<div id="HSpace">
    <jsp:include page="Header.jsp" flush="true" />
</div>

<div id="MSpace">
    <jsp:include page="Main.jsp" flush="true" />
</div>

<div id="TSpace">
    <jsp:include page="Tail.jsp" flush="true" />
</div>
Leo Choi
  • 9
  • 3