0
私は製品グリッドを持っており、各製品はiframeウィンドウを開くための一意のIDでjavascriptを呼び出します。 最初のものを呼び出すときは機能しますが、2番目のものを呼び出すときは何もしません。 私はそのスクリプトを呼び出す必要がある約20の製品を持っています。2つ以上の関数がJavascriptで実行できない
2番目のiframeを呼び出すときに可能であれば、最初に閉じる、2番目に表示するなどが必要です。ここで
はスクリプトです:
function init() {
test = true;
document.getElementById('go<?php echo $product['product_id']; ?>').onclick = function() {
ifr = document.createElement('iframe');
ifr.setAttribute('src', this.href);
ifr.src = this.href;
ifr.setAttribute('id', 'iframe_a<?php echo $product['product_id']; ?>');
if (test == true) {
ifr.onreadystatechange = function() {
if (this.readyState == 'complete<?php echo $product['product_id']; ?>') {}
}
document.getElementById('iframe_a_container<?php echo $product['product_id']; ?>').appendChild(ifr);
test = false;
}
return false;
}
}
window.addEventListener ?
window.addEventListener('load', init, false) :
window.attachEvent('onload', init);
のiframeコード:
<div id="iframe_a_container<?php echo $product['product_id']; ?>"> </div>
とボタンのコード:
<a id="go<?php echo $product['product_id']; ?>" href="index.php?route=product/quickview&product_id=<?php echo $product['product_id']; ?>">Quick View</a>
あなたの方法では、ボタンがちょうどいない機能を持つhrefのような役割を果たします。 スクリプトが機能しなくなります。それはonclickの内側です。ここに作業スクリプトhttp://www.petite-style.com/tea(製品の下のクイックビューボタン)があります。 –
はonmouseoverで試してみましたが、あなたのコードを少し変更して動作しますが、それは仕事をしません。 –