2013-10-24 74 views
1

下面我有一個「按鈕」(只是一個帶圖標的跨度),它在我的應用程序中創建了一個div的彈出視圖,以允許用戶比較獨立的窗戶。Asp.Net中的Javascript/jquery彈出窗口MVC4

不過,我得到和Asp.Net錯誤如下:

* *在 '/' 應用程序的服務器錯誤。

無法找到該資源。 請求的URL:/首頁/的翻譯:**

有沒有人有這是爲什麼happending的想法?下面是我的代碼:

<div class="module_actions"> 
<div class="actions"> 
<span class="icon-expand2 pop-out"></span> 
</div>  
</div> 
<script> 
    $(document).ajaxSuccess(function() { 

    var Clone = 
    $(".pop-out").click(function() { 
     $(this).parents(".module").clone().appendTo("#NewWindow"); 
    }); 

    $(".pop-out").click(function popitup(url) { 

     LeftPosition = (screen.width) ? (screen.width - 400)/1 : 0; 
     TopPosition = (screen.height) ? (screen.height - 700)/1 : 0; 
     var sheight = (screen.height) * 0.5; 
     var swidth = (screen.width) * 0.5; 

     settings = 'height=' + sheight + ',width=' + swidth + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable=yes,toolbar=no,status=no,menu=no, directories=no,titlebar=no,location=no,addressbar=no' 

     newwindow = window.open(url, '/Index', settings); 
     if (window.focus) { newwindow.focus() } 
     return false; 
    }); 
}); 

+0

如果用+代替',',你會在行window.open上得到什麼? –

+0

如果我添加網址+「索引」+設置我得到 請求的URL:/家庭/ [對象對象]/Indexheight = 540,寬度= 960,頂部= 380,左= 1520,scrollbars =是,resizable =是, toolbar = no,status = no,menu = no,directories = no,titlebar = no,location = no,addressbar = no 如果我加url +「Index」,設置 /Home/[object Object]/Index – Mark

+1

上面的代碼將窗口的標題設置爲'/ Index'我假設這就是你想要的標題...如果這應該被附加到網址,那麼你應該把一個+在那裏...但是...你仍然需要修復url來連接有效的url而不是javascript對象。 – Kevin

回答

1

你上面的代碼將設置窗口的標題是「/索引」。如果您希望將其作爲URL的一部分,則需要將其更改爲+以將其連接到url字符串。然而,你的url仍然有問題,因爲無論你在構造你的url,你都會追加一個對象而不是字符串到它的末尾。

[object Object] 

JavaScript是如何串接一個對象到串上,並明確根據窗口請求了錯誤的URL的錯誤消息。