亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SVG 內容從 IFrame 文檔內容中消失

SVG 內容從 IFrame 文檔內容中消失

慕后森 2022-12-09 19:46:10
我正在嘗試復制模式內特定 IFrame 元素中的內容以避免不必要的數據庫調用。我正在通過 Python 調用客戶端回調(請參閱此處),它返回我想在模式中復制的特定 IFrame 元素的索引。這是 Python 代碼片段,它切換我的模式并跟蹤最近單擊的要復制的圖形的索引:@app.callback(    [Output('my-modal', 'is_open'),    Output('modal-clone', 'children')],    [Input(f'button{k}', 'n_clicks_timestamp') for k in range(20)] +     [State('my-modal', 'is_open')])def toggle_modal(*data):    clicks, is_open = data[:20], data[20]    modal_display = not is_open if any(clicks) else is_open    clicked = clicks.index(max(clicks))    return [modal_display, clicked]app.clientside_callback(    ClientsideFunction(namespace='clientside', function_name='clone_figure'),    Output('modal-test', 'children'),    [Input('modal-clone', 'children'), Input('modal-figure', 'id')])以及以下 Javascript:window.dash_clientside = Object.assign({}, window.dash_clientside, {    clientside: {        clone_figure: function(clone_from, clone_to) {            source = document.getElementById(clone_from);            console.log(document.getElementById(clone_to))            console.log(document.getElementById(clone_to).contentDocument);            clone = document.getElementById(clone_to);            // set attributes of clone here using attributes from source            return null        }    }});現在,從我的console.log()陳述中,我注意到以下內容(請注意,modal-clone在屏幕截圖中對應modal-figure于我的示例):contentDocument這兩個日志語句之間的變化如何?任何見解將不勝感激,我很難過。
查看完整描述

1 回答

?
白衣非少年

TA貢獻1155條經驗 獲得超0個贊

看來您需要addEventListener()IFrame 元素:


clone_spray: function(clone_from, clone_to) {


    source = document.getElementById(clone_from);

    clone = document.getElementById(clone_to);


    if (!clone) {return null;}


    clone.addEventListener("load", function() {


        // set attributes of clone here using attributes from source


查看完整回答
反對 回復 2022-12-09
  • 1 回答
  • 0 關注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號