• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Odd jscript problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Odd jscript problem

    Only a bloggy thing at moment so not important but annoying!! Using Google Youtube api to kick off another function when someone starts a youtube video. The change state handlers below work fine, and the function gets called if you start either video. But it then won't call the function for the other video even though the handler is called and state is correct.

    To be a bit clearer say I start video 1 first. The alert in changeplay1 reports state to be 1 and the lyrics function is called. If I start video 1 second the alert in changeplay1 still reports state to be 1 and yet the function does not get called. If state is 1 how can if (state==1) suddenly not work? Wierd.

    function changeplay2(state)
    {
    alert("Player 2 new state:X" + state + "X");
    if (state==1) showlyrics('showlyrics2','lyriclines2','lyrictimes 2');
    }
    function changeplay1(state)
    {
    alert("Player 1 new state:X" + state + "X");
    if (state==1) showlyrics('showlyrics1','lyriclines1','lyrictimes 1');
    }
    function showlyrics(showline,llist,tlist)
    {
    alert("LYRICS ",showline);
    etc


    Have tried "1", 1*state etc in case state is a string or has appended spaces etc. There are no jscript errors. Any other bright ideas?

    Cheers.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

    #2
    Are you sure it's the comparison that's failing? Have you tried

    if (state==1) alert("true");

    Comment


      #3
      You're right! It's the call that is failing not the test.

      Still no idea why the call fails when there is no jscript error and a dummy function with the same arguments is ok. Have to comment the lines out and see why.

      Thanks very much k2p2.
      bloggoth

      If everything isn't black and white, I say, 'Why the hell not?'
      John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

      Comment


        #4
        I would recommend installing Firebug if you haven't already. You can use the Javascript debugger to stick some breakpoints into the code and see what's happening.

        Comment


          #5
          Cheers. Got firebug and IE has summit similar now. Ought to get round to using em instead of sticking alert stas in. Nostalgia for ZX81 days probably.
          bloggoth

          If everything isn't black and white, I say, 'Why the hell not?'
          John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

          Comment


            #6
            Originally posted by xoggoth View Post
            Cheers. Got firebug and IE has summit similar now. Ought to get round to using em instead of sticking alert stas in. Nostalgia for ZX81 days probably.
            Yeah, nothing wrong with a few alerts but the debugger is much more comprehensive. Lets you step through and check what the variables and objects contain at each step. Check out the script and console tabs in Firebug, that's where the useful stuff is.

            Comment

            Working...
            X