1

When we execute a search request we can get back a list of matching questions. One of the properties of the response is called "link" which is a URL to the question itself.

In my application, I wished to open this URL within an HTML <iframe> within the page but it doesn't work. Why is this?

2

When an HTTP request to show a page is sent to the Stack Exchange web site, a check is explicitly made to ensure that returned page is not loaded into an <iframe>. The response header that comes back for X-Frame-Options is SAMEORIGIN which means that only pages loaded from the same origin can be included in the <iframe>. There are good reasons for restricting pages from being loaded within <iframe>s and Stack Exchange have deliberately chosen this policy.

The bottom line is don't try and load pages from Stack Exchange within your own <iframe>s, they won't work by design and intent.

To read more about the X-Frame-Options response, read the documentation and the technical spec in RFC7034.

0

You are not supposed to open Stack Exchange sites in an iframe and doing so might violate the terms of service.
Also, attempting to do this is part of a technique used by cyber-criminals ("clickjacking"). You don't want to look like one of them. ;)

If you try, your browser will give you errors like:

Load denied by X-Frame-Options: http://meta.stackexchange.com/{etc.} does not permit cross-origin framing.

You can look up "iframe buster, busters" and try to beat the system, but the correct/allowed way to mash up two or more web pages is to pull Stack Exchange data from the Stack Exchange API.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .