www.webdeveloper.com
Results 1 to 2 of 2

Thread: Null reference error in javascript function?

  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Null reference error in javascript function?

    İ 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?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Quote Originally Posted by mobilya View Post
    ... 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?
    tb_show is not a function because it has never been defined in the code you gave, so what should you do?
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles