Click here to Skip to main content
14,302,396 members
Rate this:
Please Sign up or sign in to vote.
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
<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.
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
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100