• 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

xoggoth

More fingers than teeth
Thanks received
1,183
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','lyrictimes2');
}
function changeplay1(state)
{
alert("Player 1 new state:X" + state + "X");
if (state==1) showlyrics('showlyrics1','lyriclines1','lyrictimes1');
}
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.
 
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.
 
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.
 
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.
 
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.
 

Advertisers

Back
Top