1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Null reference error in javascript function?

Discussion in 'JavaScript' started by karinca, Apr 30, 2012.

  1. #1
    İ want to use this code but when the page opens, I get a null reference error. When I open the page a second time, this error doesn't occur.

    I understand when the site caches, this error doesn't occur. The error comes from tb_show function.


    My code:
    <script type="text/javascript">

    function writeCookie(CookieAdi) {
    var dtGun = 1
    var strValue = "1"
    if (dtGun == null || dtGun == "") dtGun = 365;
    var d = new Date();
    d.setTime(d.getTime() + (dtGun * 24 * 60 * 60 * 1000));
    var zt = "; expires=" + d.toGMTString();
    document.cookie = CookieAdi + "=" + strValue + zt + "; path=/";
    }

    function readCookie(cookieadi) {
    var c = document.cookie;
    if (c.indexOf(cookieadi) != -1) {
    s1 = c.indexOf("=", c.indexOf(cookieadi)) + 1;
    s2 = c.indexOf(";", s1);
    if (s2 == -1) s2 = c.length;
    strValue = c.substring(s1, s2);
    return strValue;
    }
    }


    writeCookie('OnerFacebook');


    if (readCookie('OnerFacebook') != 1) {
    tb_show('', 'http://www.mobilyala.com/OnerFacebook/?KeepThis=true&TB_iframe=true&height=500&width=300&modal=true', '');
    }


    </script>

    What should I do for it?
     
    karinca, Apr 30, 2012 IP
  2. Alejandro131

    Alejandro131 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    3
    Trophy Points:
    21
    #2
    The code that you have given isn't sufficient enough for us to determine where your null reference error comes from.

    The function tb_show isn't actually defined, which might actually be your problem.

    Unless you post your full source code or a demo link for us to see the page and get the error ourselves, I guess there isn't much we can do with the information you have given us.
     
    Alejandro131, Aug 4, 2012 IP