开发者

set tab in new window using window.open

I have two pages name one.php and two.php in one.php i have a combo box which has a option values like

开发者_如何学Gooption  value='0'
option  value='1'
option  value='2'
option value ='3'    

Now when on change event of combo box fires i am opening one new window named 'two' as follows

$('#sel').live('change',function(){

var tindex=$(this).val();

//Open a new window and pass tab index 

window.open('two.php#tabs-'+tindex,'two');

});

for the first time new window is opened correctly and ui tab is set accordingly but if i chose another value in combo box lets say '1' then url in a same new window is changed but tab is not set accordingly.


You can save a reference to the window object returned by open, to get the window object for the popup.

You can then make a function in the popup window that changes the current tab, and call that function from the main window.

For example:

var popup = window.open('two.php#tabs-'+tindex,'two');
popup.setActiveTab(tindex);

In the popup window, you can write

window.setActiveTab = function(newIndex) {
    //Do something
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜