2014年7月20日日曜日

XML名前空間 Javascript

XML名前空間 Javascript


document.documentElement.namespaceURI

element.getElementsByTagNameNS

与えられた名前空間に属し、与えられたタグの名前を持つ要素のリストを返します。


例:
document.getElementsByTagNameNS("http://itunes.apple.com/rss","image")


a=date.getElementsByTagName('entry')[0]
a.getElementsByTagNameNS('http://itunes.apple.com/rss','image');

2014年7月19日土曜日

javascript オブジェクト 作成、プロパティ、メゾット

javascript オブジェクト 作成、プロパティ、メゾット


<script text="text/javascript">

var j = function (e){
        var x=0;
        var opt = {};

        opt.a =function (){
                x=x+1;
                return x;
  }();

        opt.b = function(){
                x=x-1;
                return x;
        };

        opt.c = function(){
                return "opt.c";
        };

        opt.d = function(){
                return "opt.b";
  }();

        opt.e = function(x){
                console.log(x);
                console.log(e);
                return x;
        };

        opt.f = function(x){
                return x;
        }(e);

        return opt;
}("引数");

</script>


実行の結果:



2014年7月10日木曜日

Adsense 広告の表示時間を指定

Adsense 広告の表示時間を指定するためのJavascript です。


前略




<br />
<div id="get">
</div>
<script type="text/javascript">
setTimeout("adse()",5000);

function adse(){
        var get = document.getElementById("get");
        var newel = document.createElement("script");
            newel.async = true;
            newel.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
        var inst = document.createElement("ins");
            inst.className="adsbygoogle";
            inst.style.cssText = "display:inline-block;width:300px;height:600px";
            inst.setAttribute("data-ad-client", "ca-pub-0000000000000000");
            inst.setAttribute("data-ad-slot", "0000000000");
  newel.appendChild(inst);
  get.appendChild(newel);
}

</script>