javascript
  • asp.net
  • .net
  • hyperlink
  • 2016-05-23 52 views 0 likes 
    0

    我有以下ASP.Net中聲明的超鏈接。NavigateUrl =「#」導航到下一頁 - ASP.Net超鏈接

    <asp:HyperLink ID="lblPostcode" runat="server" Text='<%# Eval("POSTCODE") %>' 
    NavigateUrl="#" Target= "_blank" 
    onClick ='<%# String.Format("ViewGoolgeMap(\"{0}, {1}, {2}\")",Eval("ADDRESS").ToString(),Eval("TownCITY").ToString(),Eval("POSTCODE").ToString())%>' /> 
    

    以下JavaScript方法,從上面的超鏈接調用。

    function ViewGoolgeMap(pid) { 
    
         window.open("https://www.google.co.uk/maps/place/" + pid + "", "Map" + pid, "width=500px,height=520px,left=20,top=20"); 
    
        } 
    

    實際結果是,它是打開彈出,但打開彈出之後,它定位到了錯誤的網頁說,

    HTTP Error 403.14 - Forbidden 
    The Web server is configured to not list the contents of this directory. 
    

    Error Message

    所需的解決方案是它應該打開彈出窗口。沒有其他事情需要做。

    很多謝謝。

    回答

    0

    onClick處理程序返回false將停止頁面執行href

    function ViewGoolgeMap(pid) { 
        window.open("https://www.google.co.uk/maps/place/" + pid + "", "Map" + pid, "width=500px,height=520px,left=20,top=20"); 
    return false; //Changed here 
    
        } 
    
    +0

    已經做同樣的事情......但沒有用的。 –

    +0

    您還應該在'onclick'事件處理函數中返回該值:'onclick ='<%#String.Format(「return ViewGoolgeMap(...'。 – ConnorsFan

    相關問題