アプリ版:「スタンプのみでお礼する」機能のリリースについて

お世話になります。

以下の構文が記載されたPHPをhtmlからjavascriptにて呼び出してます。
が、うまく広告が表示されずに困っています。
PHPを直接叩き、document.write等を削除したものを
直接htmlに貼り付ければ、広告は表示されます。

広告が表示されない原因としては、adsenseのscript内でinframeを作成しているのですが
その歳のwidth,heightが0になってしまっているようです。
しかし、なぜその値が渡せていない?のかが解らずハマっています。


<?php
header("Content-type: application/x-javascript");

echo "document.write(\"<div align='center'>\")\n";
echo "document.write(\"<p>\")\n";
echo "document.write(\"<script type='text/javascript'><!--\")\n";
echo "document.write(\"google_ad_client = 'hogehogeID';\")\n";
echo "document.write(\"/* 200*200 */\")\n";
echo "document.write(\"google_ad_slot = 'slotnumber';\")\n";
echo "document.write(\"google_ad_width = 200;\")\n";
echo "document.write(\"google_ad_height = 200;\")\n";
echo "document.write(\"//-->\")\n";
echo "document.write(\"</script>\")\n";
echo "document.write(\"<script type='text/javascript'\")\n";
echo "document.write(\"src='http://pagead2.googlesyndication.com/pagead/show …\")\n";
echo "document.write(\"</script>\")\n";
echo "document.write(\"</p>\")\n";
echo "document.write(\"</div>\")\n";
?>

adsenseコード中にコメントが使用されているのですが
このあたりが怪しいと思いますが・・・

博識な方、よろしくお願い致します。

A 回答 (2件)

#phpソースで質問するから、そっちの指摘が先になってしまってますね(汗



下記内容の『外部JSファイル』を呼び出しても思った動作をしないということで質問された方がいいと思います(ブラウザには下記の内容が返っているだけですから)。

document.write("<div align='center'>")
document.write("<p>")
document.write("<script type='text/javascript'><!--")
document.write("google_ad_client = 'hogehogeID';")
document.write("/* 200*200 */")
document.write("google_ad_slot = 'slotnumber';")
document.write("google_ad_width = 200;")
document.write("google_ad_height = 200;")
document.write("//-->")
document.write("</script>")
document.write("<script type='text/javascript'")
document.write("src='http://pagead2.googlesyndication.com/pagead/show …")
document.write("</script>")
document.write("</p>")
document.write("</div>")


(参考)
http://oshiete.goo.ne.jp/qa/7716000.html

この回答への補足

ご回答ありがとうございます。

>#phpソースで質問するから、そっちの指摘が先になってしまってますね(汗
>ブラウザには下記の内容が返っているだけですから

「PHPをhtmlからjavascriptにて呼び出してます」と記載しているので
伝わるかなと思っているのですが。。。

ご指摘通り、質問し直します。

補足日時:2012/09/28 12:49
    • good
    • 0

ふつうなら こんなふうに かかない?(PHPも、ていれべるだけど)


こいに みづらく かいているの?

<?php
header("Content-type: application/x-javascript");


echo <<<EOF_HTML
<div align="center">
 <p>
 <script type="text/javascript">
 var google_ad_client = 'hogehogeID';
 var google_ad_slot = 'slotnumber';
 var google_ad_width = 200;
 var google_ad_height = 200;
 </script>
 <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show …
 </p>
</div>
EOF_HTML;
?>

この回答への補足

前提条件があり見づらくなっています。
1.htmlからphpが呼び出せないので、javascript経由で実行しています
2.echo "document.write 以降に記載しているコードは改変できません

ちなみに上記内容ではNGでした。(何も実行されない→前提1に該当?
特に極めようとか思っていなくて、思い通りに出力できれば満足でして
今回はその結果について質問しています。
実際に出力できる結果を導けないならコメント不要です。
できなくて、またがっかりするの嫌なんで。
ありがとうございました。

補足日時:2012/09/25 16:35
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!