Fiddle
为什么同一时间只有一个 iframe 可以工作?我的 JavaScript 有问题吗?
function test(){
document.getElementById('src1').src='http://cnn.com/'
}
function test1(){
document.getElementById('src2').src='http://stackoverflow.com/'
}
test();
test1();
最佳答案
它确实有效,只是 stackoverflow 出于安全原因阻止您将其 URL 嵌入到 iframe
中......
您可能会看到,即使 Google 也会阻止用户嵌入要在 iframe
中使用的 google URL
function test1(){ //Alter the URL in this function
document.getElementById('src2').src='https://stackoverflow.com/'
}
关于javascript - 为什么不同 div 元素中的 iframe 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17521055/