c# - 如何在 iframe 中捕获图像(url)?

标签 c# javascript jquery asp.net iframe

我在这里 try catch iframe 中的图像(url)。但它不起作用。这是我的代码:

<div id="iframe">
    <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="border2">
        <tr>
            <td height="403">
                <asp:UpdatePanel ID="Update" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <iframe id="IFTrendAnalysis" name="IFTrendAnalysis" scrolling="auto" runat="server" width="100%" height="403" frameborder="0"></iframe>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="imgBTNSalesTrendChart" />
                    </Triggers>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>
</div>

和图片路径(动态生成)

http://10.232.151.132:8080/pentaho/getImage?image=picture658447691538512233.png

$(function () {
    $("#MainContent_IFTrendAnalysis img").click(function () {
        var update = $("<div>").append(
            $("<img>").attr("src", $(this).attr("src"))
        ).html();

        $("#content").val(function (i, v) {
            return v + update;
        });
    });
});

有什么建议吗?

最佳答案

如果您的 iframe 页面与父页面在同一个域中,那么这应该可以帮助您:

var name = "img_Sample";
$('#MainContent_iframeDetail').get(0).contentWindow.document.getElementById(name).src

我想,您也应该能够使用 Jquery 代替 document.getElementByID

关于c# - 如何在 iframe 中捕获图像(url)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10350678/

相关文章:

jquery - knockout 列表与无序列表的绑定(bind)

c# - 给定排序字符串的游程编码

c# - 阻止 Visual Studio 中断任务中的异常

javascript - 如何在javascript中使用同一对象中的公共(public)方法访问私有(private)变量?

javascript - 如何仅从一个div添加一个滚动条到另一个div

jquery - 当 mouseleave() 的当前选择器时中断 mouseenter 动画

c# - 如何使用 'with' 关键字添加?

c# - 如何将项目类型转换为共享类库类型

javascript - 如何使用javascript为多个标签设置唯一id

jquery - 如何使用jquery获取href属性?