JavaScript+Cookie版サンプル - トップページ


代理店コード:

<script type="text/javascript">
<!--
function setCookie() {
    var param = parent.top.location.search;
    if (param.length) {
        theName = "bannerCode";
        theValue = param.substr(1);
        theDay = 7;
        setDay = new Date();
        setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
        expDay = setDay.toGMTString();
        document.cookie = theName + "="+escape(theValue)+";expires="+expDay;
        return true;
    } else {
        return false;
    }
}

setCookie();

theName = "bannerCode=";
theCookie = document.cookie+";";
start = theCookie.indexOf(theName);
if (start != -1) {
    end = theCookie.indexOf(";",start);
    theData = unescape(theCookie.substring(start+theName.length,end));
}
//-->
</script>

<script type="text/javascript">
<!--
document.write(theData);
//-->
</script>