button for adding a tab

the following code is able to add a tab, if such code is not inside the tab content.

function add(pos) {
    var id = (new Date()).valueOf();
    tabbar.addTab(id, "new tab", "*");
    tabbar.setTabActive(id);
}

<a href="javascript:add(-1);">new tab</a>

How can I add a new tab using a button sited inside the tab content???

if the content is an iframe, you should use parent to address the variables in parent window:

function add(pos) {
var id = (new Date()).valueOf();
parent.tabbar.addTab(id, “new tab”, “*”);
parent.tabbar.setTabActive(id);
}