0

I'm trying to load a webpage into a div...But It's not getting loaded into the div...instead it's loading as a whole webpage....why??

<li><a href="#" onClick="AboutUs();">About&nbsp;Us</a></li>
<div class="bdy"></div>

javascript code:

function AboutUs () {
    // body...
//$('.bdy').load('http://www.jhsoftech.com' );
$('.bdy').html('<object style="width:100%;height:435px;" data="http://www.erail.in">');
}

2 Answers2

1

I opened your site in an iframe sandbox.

JSFIDDLE Example

$('.bdy').html('<iframe sandbox="allow-scripts" style="width:100%;height:435px;" src="http://www.erail.in"><iframe>');
})

The problem with your site, setting another location / redirecting the page is this part of code on the your site:

if(top!=self)top.location.href="http://erail.in";

Remove this and you are able to implement it without a sandbox preventing allow-top-navigation.

Kilian Stinson
  • 2,376
  • 28
  • 33
  • thank you...Kilian Stinson...but if the link is www.erail.in/?R=12622. What to do..Here, First page loads and then the content loads dynamically If I directly give this link in your code...the content is not getting loaded i.e., the information of the train no.12622..what to do?? – user2458719 Jun 21 '13 at 08:09
  • Try adding `allow-same-origin` to the `sandbox` attribute. http://jsfiddle.net/JKZ2h/1/ – Kilian Stinson Jun 21 '13 at 08:17
  • thank you...Kilian stinson It works...fine.. If I had to do with load function..can you tell me...how to do that..?? I am asking because if I can do it with load...I can display only the table I wanted to display... – user2458719 Jun 22 '13 at 08:01
  • http://api.jquery.com/load/ is limited to the same domain/subdomain, so this won't work. – Kilian Stinson Jun 24 '13 at 07:21
0

Just change to

<div class="bdy"></div>

And use jquery take a look at this one http://jsfiddle.net/markipe/TEHsJ/

Markipe
  • 616
  • 6
  • 16