为什么这个onclick事件不会运行我的iframe函数?

时间:2016-12-28 07:15:50

标签: javascript html onclick

为什么这个iframe不起作用?我无法弄清楚。它运行得很好而无需从onClick调用。

function paymentMethods() {
  var x = document.createElement("IFRAME");
  x.setAttribute("id", "paymentIframe");
  // DELETE
  var y = ("tml_text.asp");
  //Change link to payments link and change y to accountID
  var z = ("http://www.w3schools.com/jquery/h" + y );
  x.setAttribute("src", z);
  x.height = "700";
  x.width = "500";
  $("#iframeDiv1").append(x);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="iframeDiv1"></div>
<div id="iframeDiv2"></div>
<button id="paymentMethodsBtn" onClick="paymentMethods()">Payment Methods</button>

0 个答案:

没有答案