Jquery:从一个页面重定向到另一个页面

时间:2012-05-25 06:42:21

标签: jquery html

我在两个不同的位置有两个js页面(Source.js和Target.js),现在我想要做的就是当用户点击源页面的下拉列表时,它会将用户重定向到目标页面,反之亦然。我正在为您提供所有位置和外包的确切编码,我只想知道如何从一页切换到第二页。

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”

1 个答案:

答案 0 :(得分:1)

试试这个......(仅举例)

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