我需要更改父級iframe中div的backgroundImage。Javascript backgroundImage url css change
我可以做到這一點,但不是以有用的方式,我需要從按鈕發送變量。
目前我在腳本中有變量。
<script>
function myFunction() {
window.parent.document.getElementById('seekerBase').style.backgroundImage = "url('http://www.floom.com/images/waveform_lotos.gif')";
}
</script>
<button type="button" onclick="myFunction()">Get the background image of div</button>
我需要從按鈕發送圖像URL,而不是在腳本中。
我試過這個,並沒有工作。
<script>
function myFunction() {
window.parent.document.getElementById('seekerBase').style.backgroundImage = "url()";
}
</script>
<button type="button" onclick="myFunction('http://www.floom.com/images/waveform_lotos.gif')">Get the background image of div</button>
感謝您的幫助。 我是新手。
將它作爲參數'function myFunction(img){...}' – Jasen