2016-04-25 18 views
0

こんにちは、私は私がコンソールにこのエラーを取得していパス、現在のページのURLは

<iframe src="http://localhost/ 
<script type="text/javascript"> 
document.write(window.location.pathname); 
</script> 
.html" frameborder="0" scrolling="no" onload="resizeIframe(this)" /> 

このHTMLを使用してい

<iframe src="http://anydomain.com/frame.php?ref=http://currentpageurl.com/dir"></iframe> 

のようなものを取得しようとしている

Failed to load resource: the server responded with a status of 403 (Forbidden) 
GET http://localhost/%3Cscript%20type=/ 
+0

これはあなたのiramesのsrcがあるので 'のhttp:// localhost /を <スクリプトタイプ=' –

答えて

1

あなたが行っていると思われる純粋なJSソリューション(ただし、サーバー側のレンダリング中にこれを行うことをお勧めします)では、 omethingこのような:

<script type="text/javascript"> 
     var iframe = document.createElement('iframe'); 
     iframe.src = 'http://anydomain.com/frame.php?ref=' + window.location.href; // if you just want the path change `href` to `pathname` 
     document.body.appendChild(iframe); // insert the element wherever you want in the page 
</script> 
関連する問題