Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.32/5 (4 votes)
Hi,

I want to show the content of any external www.xyz.com website in my web project that is built using ASP.NET/C#.

- so far I have tried the HTML iframe tag
HTML
<iframe id="myiframe" src="https://developer.mozilla.org/en/docs/Web/HTML/Element/iframe"></iframe>

and this does not display anything (empty iframe) because this tag only works with pages that are within (contained) in my own project.

- I also tried to use JQuery to load the content into a div tag using the following JQuery load function but nothing seems to work.
JavaScript
jQuery(document).ready(function () {
  $("#testLoad").load("http://www.google.com");´
});


this code just return error Not Found for any website, but trust me, www.google.com it does exists.

any idea how can I achieve this approach of loading the content of any external website within an iframe or with any other alternative using C#?

Thanks in advance!
Posted
Updated 24-Apr-23 19:35pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Oct-14 17:33pm    
What can it possibly mean, "load website"? :-)
Why? You can always point to any resource in any accessible site using an anchor...
Your cross-domain policy may prevent doing it with an external domain. This is generally a bad thing. Use your own resources, and reference other sites using an anchor.
—SA
Santiago Fabian 28-Oct-14 19:43pm    
load website = show a website embeded in my own page. If you have ever used the iframe tag you will know what I mean. Actually, I´m not trying to access any external resources in fact, I just want to embed any website page within the iframe tag but my problem is that the website is not being displayed in the iframe. I put that link in the src attribute just as an example, not meaning that I effectively want to access to an anchor of another website page.
Sergey Alexandrovich Kryukov 28-Oct-14 20:25pm    
Okay, you want to load the page (not site) and embed it in one of your HTML elements. I already answered: 1) your cross-domain policy may prevent doing it with external Web site; 2) I would not recommend doing it.
Did you try "general" jQuery .Ajax()?
—SA

1 solution

You can do it in simple way using jQuery UI library.
As displayed in below example :-

http://jsfiddle.net/smrutis1984/qar7zf03/5/

Hope will be helpful.
 
Share this answer
 
Comments
Santiago Fabian 4-Nov-14 12:45pm    
Effectively. That's a great solution. Thanks! :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900