2012-05-25 273 views
2

我有兩個js頁面(Source.js和Target.js)在兩個不同的位置,現在我想要做的是當用戶點擊源頁面的下拉列表,它將用戶重定向到目標頁面,反之亦然。我正在爲您提供所有位置和everthing的確切編碼,我只想知道如何從一個頁面切換到第二個頁面。jquery:從一個頁面重定向到另一個頁面

Source.js編碼

var SourceSc = function() { 
var that = {}; 
var _view = null; 
var _childPanel = "#content"; 
var _sourceDlgMgrC = null; 
var BEGIN = "BEGIN"; 
var STARTING = "STARTING"; 
var END = "END"; 
var TARGET = "TARGET"; 
var _state = BEGIN; 
that.create = function(parent, panel) { 

    _parent = parent; 
    _panel = panel; 
    _transition(STARTING); 
}; 
that.destroy = function() { 
    _transition(END); 
}; 
that.eventTargetLanguageView = function() { 
    _transition(TARGET_LANGUAGE_VIEW); 
}; 
var _transition = function(newState) { 
    _state = newState; 
    switch(_state) {     
     case STARTING: _enterStarting(); break; 
      case TARGET: _enterTargetDlg(); break; 
     case END: _enterEnd(); break; 
    } 
}; 
var _enterStarting = function() { 
    modelMgr.loadInclude('code/app/sc/LoggedIn/sc/Source/c/SourceDlgMgrC.js', function() { 
     modelMgr.getHTML('code/app/sc/LoggedIn/sc/Source/Source.html', function(html) { 
      _sourceDlgMgrC = SourceDlgMgrC(); 
      _sourceDlgMgrC.create(_childPanel); 
      var req = {}; 
      var fnSuccess = function(res) { 
       _view = SourceV(); 
       _view.create(that, _panel, html, res);     
      };    
     }); 
    }); 
}; 
var _enterTargetDlg = function() 
{ 
//now what i have to write here, to load target page 
}; 
var _enterEnd = function() { 
    //coding of destroy  
}; 
return that;}; 
var SourceV = function() { 
var that = {}; 

var _sc = null; 
var _panel = null; 

that.create = function(sc, panel, html, res) { 
    _sc = sc; 
    _panel = panel; 
    that.layoutUi(html); 
    that.bindEvents(); 
}; 
that.layoutUi = function(html) { 

    $(_panel).html(html);  
}; 
that.bindEvents = function() { 

    $('#viewList').change(_sc.eventTargetLanguageView); 
}; 
that.destroy = function() { 
    $(_panel).html(''); 
    _panel = null; 
    _sc = null; 
}; 
return that; }; 

我可以張貼source.html全編碼,但我想那會沒有那麼使用我會後僅下拉列表編碼

<select id = "viewList" class="fl width160"> 
      <option>Source</option> 
      <option>Target</option> 
     </select> 

現在目標頁面的編碼也完全相同,但Target.js的位置是「code/app/sc/LoggedIn/sc/Target/Target.js」

+0

怎麼樣'location.href ='yourNewPage';'? – mattytommo

+0

@mattytommo請更清楚 –

+0

要轉到另一個頁面,不能只是執行代碼'location.href ='yourNewPage';'。這會將瀏覽器重定向到一個名爲'yourNewPage'的頁面。 – mattytommo

回答

1

試試這個......(舉個例子)

codeLoadingMgr.loadInclude(path + '/AdminSc.js', function() { 
_adminSc = AdminSc(); 
    _adminSc.create(that, path, _childPanel,_selectedAdminTab, _programId); 
    }); 
+0

非常感謝,它幫助:) –

+0

您的歡迎vikas ..! –

相關問題