1

I tried loading using jQuery $get and $ajax but getting Origin issue.

I looked JSON-p but it is only for JSON data.

I tried with yahooApi it worked, but how stable and reliable is yahooApi? I mean, in the future if I implement using it and if they stop supporting it, my code will stop working.

Don't we have any other alternative to load external pages in DIV?

Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99
Dev G
  • 1,387
  • 4
  • 26
  • 43
  • possible duplicate of [Getting around same origin policy in javascript without server side scripts](http://stackoverflow.com/questions/2067029/getting-around-same-origin-policy-in-javascript-without-server-side-scripts) – JJJ May 16 '12 at 15:15
  • This is what I explained my Other workaround I believe can be achieved is using hidden iframe in page and then read it's content for manipulation. Means no other option is available – Dev G May 16 '12 at 15:16
  • You can always use a server-side script to load and serve external pages. Well, always when server-side scripts are available. – JJJ May 16 '12 at 15:18
  • What are you trying to achive? Do you want to load the whole webpage into one DIV or just parts of it? And what about the scripts and stylesheets coming with the loaded source? Also you won't be able to manipulate an IFRAME (origin security flaw). Also, please take notice that SO does not support security gray areas (like manipulating other webpages). – Michael Seibt May 16 '12 at 15:18
  • In my application i have to load privacy policy that resides on another server and common for all applications. But I have to apply some look and feel on that. for this purpose i want to load that in a div. I need only data inside Body tag. – Dev G May 16 '12 at 15:20

2 Answers2

0

You may be looking for the load function

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

I'm not sure about cross domain with it though.

Fernker
  • 2,238
  • 20
  • 31
  • Dang you are right, perhaps a LightBox type plugin can be used. I know some of them allow opening a web page in them (and it looks really nice) – Fernker May 16 '12 at 15:27
0

If you can alter things on the external server, then you might create a JavaScript that returns the privacy policy in a document.write() and you can retrieve that from anywhere you want to. (This is basically how JSONP works.)

Extracting the entire contents of an HTML document on another server, however, will require server-side scripting.

Blazemonger
  • 90,923
  • 26
  • 142
  • 180