2016-03-01 19 views
4

我想修改一個我們有的Web應用程序,我不確定我是否可以執行正在請求的內容。我的老闆希望能夠點擊電子郵件中的鏈接,並讓我們的公司內部Web應用程序直接進入提供的URL末尾標識的頁面。當用戶點擊一個鏈接時URL路由不起作用

如果我第一次點擊下面的鏈接,它會進入我們的Web應用程序的索引頁面。如果我打開Web應用程序並再次單擊該鏈接,它將轉到URL末尾標識的正確頁面。

http://mycompanyweb.com/handbook/mycompanyprocess/#/rt/softwate/9.13_UpdateSDP 

我嘗試添加一個init(),以爲是應用程序就會首先在生命週期的哪個,我只看到在這一點上(http://mycompanyweb.com/handbook/mycompanyprocess/)的URL的這一部分。這導致我相信瀏覽器在第一次打開#時會剝離所有內容。那是對的嗎?在沒有打開Web應用程序的情況下,當用戶第一次點擊鏈接時,我能做些什麼來讓我們的Web應用程序直接進入文檔?

http://mycompanyweb.com/handbook/mycompanyprocess/ - Base URL 

#/rt - Used by our javascript engine to determine which path to take 
(dev or production). 

/software/9.13_UpdateSDP - Logical path to a web page named 6.034_UpdateSDP.htm 

我們的引擎根據URL來確定路由的位置。我假設第二次鏈接被點擊時,它轉到正確的頁面是因爲引擎已經被加載(如果瀏覽器在第二次點擊時保持打開狀態)。

$(document).ready(function() { 
// Define the routes. 
Path.map("#/:program").to(function() { 
    var program = this.params['program']; 

    if (program == "search") { 
     $("#mainContent").load("search.html"); 
    } 
    else { 
     $("#mainContent").load("views/onepageprocess.html"); 
    } 

    $("#subheader").html(""); 

    $("#headerLevelTwoBreadcrumbLink").html(""); 
}).enter(setPageActions); 

Path.map("#/:program/:swimlane").to(function() { 
    localStorage.removeItem("SearchString"); 

    var swimlane = this.params['swimlane']; 

    var view = "views/" + swimlane + ".html"; 

    $("#mainContent").load(view); 

}).enter(setPageActions); 

// Sends all links to the level three view and updates the breadcrumb. 
Path.map("#/:program/:swimlane/:page").to(function() { 
    var page = this.params['page']; 

var url = "views/levelthree/" + page.replace("", "") + ".htm"; 

var levelThreeTitle = ""; 

    $.get(url) 
    .done(function() { 
     // Nothing here at this time... 
    }).fail(function() { 
     url = "views/levelthree/badurlpage.htm"; 

     levelThreeTitle = "Page Unavailable"; 
    }).always(function (data) { 
     $("#subheader").html(""); 

     level_three_breadcrumb = "views/breadcrumbs/breadcrumb_link.html"; 

     $("#headerLevelTwoBreadcrumbLink").load(level_three_breadcrumb); 

     $("#headerLevelThreeBreadcrumb").html(""); 

     $('#headerLevelThreeBreadcrumb').append('<img src="images/Chevron.gif" />'); 

     if (data.status != "404") { 
      $("#headerLevelThreeBreadcrumb").append(retrieveStorageItem("LevelThreeSubheader")); 
     } 

     $("#mainContent").load(url); 
    }); 

}).enter(setPageActions); 

// Set a "root route". User will be automatically re-directed here. The definition 
// below tells PathJS to load this route automatically if one isn't provided. 
Path.root("#/rt"); 

// Start the path.js listener. 
Path.listen(); 
}); 

有什麼我可以做的就是我們的Web應用程序,直接進入該文件第一次用戶點擊該鏈接時,不具有Web應用程序打開?

+0

瀏覽器不會去除網址中的任何內容。必須有東西待辦事項與您的應用程序 – delueg

+0

Sooo,我怎麼能找出在哪裏? –

回答

0

如果有人遇到類似的情況,我發現我公司的服務器在驗證URL的#後發現了任何東西。我將修改我的應用程序,以便不在URL中使用散列標記來修復它。

相關問題