簡體   English   中英

通過jQuery中的按鈕更改iFrame頁面

[英]Change the iFrame's Page by a Button Inside it via jQuery

嗨,我在default.vbhtml頁面下有這兩個iFrame,代碼是:

<iframe class="iFrameLeft" src="Page_RequestPane.vbhtml"></iframe>
<iframe class="iFrameRight" src="Page_SKUSetup.vbhtml"></iframe>

我想要做的是,當我選擇代理商並單擊“復制SKU設置”按鈕時,iFrame(通用SKU設置)將更改為其他頁面。 我定位的最終iframe是:

<iframe class="iFrameLeft" src="Page_RequestPane.vbhtml"></iframe>
<iframe class="iFrameRight" src="Page_Reseller.vbhtml"></iframe>

我所擁有的只是jQuery上的,但這是錯誤的:

$(document).ready(function () {
  $("button").click(function () {
    $('iframe').attr('src', 'Page_Reseller.vbhtml');
    return false;
  });
});

如果僅嘗試更改iFrameRight jQuery選擇器應為$('.iFrameRight')

我已經通過更改對您的代碼進行了一些修改。 您可以在下面看到它。

   $(document).ready(function () {
      $("button").click(function () {
        $('.iFrameRight').attr('src', 'Page_Reseller.vbhtml');
        return false;
      });
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM