How to improve the solution to ignore x-frame-option using JavaScript? -


this code http://jsfiddle.net/2gou4yen/ ignore x-frame-option.

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); 

this works well. problem.

for first time, doesn't work. , when refresh once, works.

so, there solution works without refresh?

have tested in other browser? in opinion it's browser problem. test in safari, google chrome, firefox.

in other way can save content in server html using serverside code , load server.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -