2016-09-10 4 views
1

私はいくつかのWordPressページ内にiFrameを埋め込もうとしています。各ページは異なるiFrameコンテンツを使用します。これは商用サイトのため、最初のiframeを顧客のログインにする必要があります。後続の別のWPページ上のiframeの製品検索のためになり、チェックアウト...((私の質問は、一番下にある))header.phpの中WordPressで閉じる/ bodyタグの後にJavascriptを追加するには

  1. は、私は私が上で含める必要があるいくつかの初期のコードを配置しましたすべてのWordPressページ。

  2. 各ページの本文内にiframeを追加しました。

  3. iframeを特定のiframeコンテンツに初期化する必要があります。私は次のように閉じ</body>タグの後にこのコードを配置したいと思います:


<html> 
    <head> 
    <script> 
     var absDomain = "http://www.webstore.com/" 
     var iframeObj; 
     var timestampString = '' + new Date().getTime() + '' 
     document.write('<script type="text/javascript" src="' + absDomain + 'Support.js?'+timestampString+'"><\/script>'); 
     document.write('<script type="text/javascript" src="' + absDomain + 'ProductSearch.js?'+timestampString+'"><\/script>'); 
     document.write('<script type="text/javascript" src="' + absDomain + 'Environment.js?'+timestampString+'"><\/script>'); 
     function gotoIframe(theLocation){ 
     var timeStamp = ""; 
     iframeObj = document.getElementById("iframeContent"); 
     timeStamp = "&" + new Date().getTime(); 
     iframeObj.src = absDomain + theLocation + "?iframe=yes" + timeStamp; 
     } 
     function executeIFrameProductSearch(str1, str2){ 
     goTo_CategoryForIframe(str1, str2, document.getElementById("iframeContent")); 
     } 
    </script> 
    </head> 
    <body> 
     <!-- iFrame embedded below --> 
     <iframe id="iframeContent" style="width:100%;height:500px; " src=""></iframe> 
    </body> 
    <script> 
     //script needed for initial iframe page and iframe support. 
     iframeObj = document.getElementById("iframeContent"); 
     gotoIframe("CustomerLogin.html"); 
    </script> 
    </html> 
    //After the above code section (after the </body> tag) is embedded into the Login page, I expect to use: 
    //Customer Login: 
    <a href="javascript:gotoIframe('CustomerLogin.html')">Customer Login</a> 
    //Product Search: 
    <a href="javascript:gotoIframe('ProductSearch.html')">Product Search</a> 

質問:私は特定のWordPressのページのそれぞれの終了タグの後のコードを挿入します?ありがとう。

+0

を表示したい場所を、私は奇妙で不思議な要件は終了タグの後に何を置くために得ることはありませんfooter.phpにこのコードを貼り付けます。あなたは精緻化できますか? –

答えて

0

bodyタグの後ろにscriptタグを置くことはできませんが、実際にそれをしたい場合は のテーマのfooter.phpを見ることができます。

<?php 
    </div><!-- close tag for content container --> 
?> 
    <footer> 
    <!-- footer content --> 
    </footer> 
    </body> 
    <!-- here is the place to put your code --> 
</html> 
+0

ありがとうございます@ucheng。それが私が探していたものです。 – Petr

+0

あなたは@Petrを歓迎しています。投票してください。ありがとうございました! – ucheng

0

コピーして(あなたのfunctions.phpファイル

 //alert(); enable alert to test 
      //script needed for initial iframe page and iframe support.`function your_function() { 
echo '<script>` 
      iframeObj = document.getElementById("iframeContent"); 
      gotoIframe("CustomerLogin.html"); 

    </script>'; 

}

add_actionでこの機能を貼り付けます。

たとえば、あなたはfooter.phpに、このようなコードを見つけることができます'wp_footer'、 'your_function'、100); //これはすべてのページのbodyタグの後にスクリプトを追加します

他のオプションは になります//この行の上にある、またはどこにでもあなたのfunctions.phpの残りの部分!

functionあなたのプレフィックススクリプト番号を入力してください。 echo ''。 $ javascript。 ''; }

add_action( 'yourprefix_after_opening_body_tag'、 'yourprefix_scripts_after_opening_body_tag');

あなたは

関連する問題