Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This problem can be easily solved by using an <strong>.htaccess</strong> rewrite. </p> <p>Demo:</p> <p>A. Create a directory named "iframeContent/" on SERVER 1.</p> <p>B. Place in that directory a file named index.php containing:</p> <blockquote> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; parent.check(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </blockquote> <p>This is the content of the iFrame. It will call a function in a parent.</p> <p>C. Create a directory named "iframeTesting_without-htaccess/" on SERVER 2.</p> <p>D. Place in that directory a file named index.php containing: </p> <blockquote> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function check() { alert("hello"); } &lt;/script&gt; &lt;iframe id="sidebnrId" name="sidebnr" src="PATH-ON-SERVER-1/iframeContent/" frameborder="0" height="500px" width="600px" scrolling="no"&gt;&lt;/iframe&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </blockquote> <p>This is simply the content of the parent windows. Just note that the iFrame content is located on another server (because on SERVER 1).</p> <p>E. Access "PATH-ON-SERVER-2/iframeTesting_without-htaccess/" with a web-browser -> nothing happens: the iframe does not have access to the function of its parent.</p> <p><strong>HERE IS HOW YOU CAN SOLVE THE PROBLEM</strong></p> <p>F. Create another directory named "iframeTesting_with-htaccess/" on SERVER 2.</p> <p>G. Place in that directory a file named index.php containing: </p> <blockquote> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function check() { alert("hello"); } &lt;/script&gt; &lt;iframe id="sidebnrId" name="sidebnr" src="content-iframe/" frameborder="0" height="500px" width="600px" scrolling="no"&gt;&lt;/iframe&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </blockquote> <p>This time the iFrame does not point anymore directly to the content on SERVER 1 but to an intermediate fictive directory "content-iframe/" located on the same server (SERVER 2).</p> <p>H. Place in that directory a .htaccess file containing: </p> <blockquote> <pre><code>Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^content-iframe/$ PATH-ON-SERVER-1/iframeContent/ [R,NC,P] </code></pre> </blockquote> <p>The role of that file is to redirect any access to the fictive directory to the content on the SERVER 1.</p> <p>I. Try again, access "PATH-ON-SERVER-2/iframeTesting_with-htaccess/" with a web-browser. This time it will work. I hope it helped :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload