为什么这个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>