0

There is a related question Overcoming "Display forbidden by X-Frame-Options" with an answer that works for loading the page thru YQL. http://jsfiddle.net/dkdnaxaq/4/embedded/result/

However, I need to be able to interact with the page as well.

With the following code,

<iframe src="https://services.mom.gov.sg/sat/satservlet" width="900" height="600"></iframe>

        <script>
        var iframe = document.getElementsByTagName('iframe')[0];
var url = iframe.src;
var getData = function (data) {
    if (data && data.query && data.query.results && data.query.results.resources && data.query.results.resources.content && data.query.results.resources.status == 200) loadHTML(data.query.results.resources.content);
    else if (data && data.error && data.error.description) loadHTML(data.error.description);
    else loadHTML('Error: Cannot load ' + url);
};
var loadURL = function (src) {
    url = src;
    var script = document.createElement('script');
    script.src = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20data.headers%20where%20url%3D%22' + encodeURIComponent(url) + '%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=getData';
    document.body.appendChild(script);
};
var loadHTML = function (html) {
    iframe.src = 'about:blank';
    iframe.contentWindow.document.open();
    iframe.contentWindow.document.write(html.replace(/<head>/i, '<head><base href="' + url + '"><scr' + 'ipt>document.addEventListener("click", function(e) { if(e.target && e.target.nodeName == "A") { e.preventDefault(); parent.loadURL(e.target.href); } });</scr' + 'ipt>'));
    iframe.contentWindow.document.close();
}

loadURL(iframe.src);
        </script>

I'm getting the following error upon load

XMLHttpRequest cannot load https://services.mom.gov.sg/sat/ssoc.jsp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Question 1: How do i add a new resource link to the YQL javascript code in order to load the page properly?

When I click on the 'I agree' button, i get the following error

    Refused to display 'https://services.mom.gov.sg/sat/satservlet' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
14:00:20.941 services.mom.gov.sg/sat/satservlet:1 POST https://services.mom.gov.sg/sat/satservlet net::ERR_BLOCKED_BY_RESPONSE

Question 2: How do I allow interaction with the page?

hansel ke
  • 21
  • 5

1 Answers1

0

managed to solve it by

1) running chrome with web security disabled

2) loading iframe in sandbox that disallows access to top

3) using jquery to remove the anti click jack css hiding code. removed the js code as well for good measure.

hansel ke
  • 21
  • 5