Cheers, but still no luck. I tried removing everything else and putting all that's left in the JS, like:
document.write("<frameset cols='170,*' rows='*' border='2' framespacing='0' frameborder='yes'>
<frame src='given.php?ref=" + document.referrer +" name='nav' marginwidth='3' marginheight='3' scrolling='auto'><frame src='index.php?pane=right' name='main' marginwidth='10' marginheight='10' scrolling='auto'>
but nothing, I'm thinking maybe that I can't do this because frames have to be in a file with nothing else, so JS cannot do this?