Javascript:检测 ascx 页面中的负载.IE浏览器

Javascript: Detect load in ascx page. Internet Explorer

本文关键字:负载 IE 浏览器 检测 ascx Javascript      更新时间:2023-09-26

我有一个下拉菜单,它将触发ChangeGraph javascript函数。 在Chrome/Firefox中,当我的部分视图(.ascx)加载时,我会收到hello警报。 在IE中并非如此。 关于如何解决这个问题的任何想法。 基本上,一旦使用"$('#GraphForm').html(data);"编写ascx页面,我就无法启动javascript函数

从我的索引.aspx:

<div id="GraphForm"></div>

Javascript:

function ChangeGraph(displayTypeId) {
    $('#GraphForm').html("");
    $.get('/Dashboard/GetGraphForm', { id: displayTypeId }, function(data) {
        $('#GraphForm').html(data);        
    });
}

控制器:

public PartialViewResult GetGraphForm(int id)
{
    //... Build Model (removed)
    return PartialView("EnergyConsumedFormView"/* , model */);
}

EnergyConsumptiondFormView.ascx Javascript:

<script type="text/javascript">
    $(document).ready(function() {
        alert('hello');
    });
</script>

我是javascript的新手,所以在我想通之前答案并不明显。 知道这似乎很明显。 如果您不在乎文档是否已准备就绪,只需调用该函数...

<script type="text/javascript">
    alert('hello');
</script>