【问题标题】:how to send php Get parameters to an iFrame?如何将 php Get 参数发送到 iFrame?
【发布时间】:2016-02-16 10:01:43
【问题描述】:

我在一个 php 页面上有多个项目,要编辑每个项目,我想将按钮的标题作为参数发送到 iFrame(弹出窗口),我该怎么做?

我有这样的代码:

<button class="btn_edit ui-button-text-only" title="245" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="246" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="247" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="248" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="249" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

itemID = 标题变量。

获得类似结果:iframe src="index.php?type=1296727025&amp;itemID.

我尝试append()但没有成功,

$dialog_edit.append($("<iframe class='no-border full-width-height' />").attr("src", "index.php?type=1296727025&tx_productmanager_pi1="+productID+"&no_cache=1"));
$dialog_edit.dialog('open');

有人有想法吗?

【问题讨论】:

  • append() 的其他代码是什么?
  • 我的附加代码是这样的: $('.btn_edit_product').click(function() { var productID = $(this).attr('title'); $dialog_edit.append($( "").attr("src", "index.php?type=1296727025&tx_productmanager_pi1[productID]="+productID+"&no_cache=1")); alert (productID); // 此警报显示产品 ID $dialog_edit.dialog('open'); return false; });

标签: javascript php jquery html iframe


【解决方案1】:

        
         
    
           $(document).ready(function(){
    
           $('.my-button').click(function() {
    
            var title = $(this).attr("title");
            var src =  "index.php?type=1296727025&itemID=" + title;
             console.log(src);
            $("#my-div").html("<iframe src='" + src + "' width='100%' height='600'></iframe>");
    
          });
    
        });
    
        
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn_edit ui-button-text-only my-button" title="245" role="button" aria-disabled="false">
  <span class="ui-button-text">Edit this item</span>
</button>
<button class="btn_edit ui-button-text-only my-button" title="242" role="button" aria-disabled="false">
  <span class="ui-button-text">Edit this item</span>
</button>
 <div id="my-div">
 </div>

  
 

【讨论】:

    【解决方案2】:

    我在本地创建了一个演示,它运行良好。请检查以下代码。由于 abc.php 不是真正的路径或文件,所以这里不会显示实际结果。

    $(document).ready(function() {
      $('#button').click(function() {
        $("#myIframe").html('<iframe id="myIframe" src="abc.php?id=12" width=500 height=500></iframe>');
        var Isrc = $("#myIframe").attr('src');
        Isrc = Isrc;
      });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
    <button id="button">Click Me</button>
    		<div id="myIframe">
    		</div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-13
      • 1970-01-01
      • 2020-08-11
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多