Javascript 更改源仅执行第一行

Javascript change source executes just the first line

嘿伙计们,如果您使用 iphone 加载我的页面,我想更改某些 iframe 的源。我的问题是它可以工作,但只有第一行其他两个 iframe 没有改变。一些想法如何解决这个问题?

     if (navigator.userAgent.match(/iPhone/i)) {
       document.getElementById("iframe-startpage-mobile").src = "placeholder_1/index.html";
       document.getElementById("iframe-vrapp-mobile").src = "placeholder_2/index.html";
       document.getElementById("iframe-360video-mobile").src = "placeholder_3/index.html";
      } 

我可能想通了为什么它不能工作:我在 wordpress fusionbuilder > avada > theme options > Space 之前插入这个,所以也许 wordpress 不让它正常工作

尝试添加如下内容:

alert(document.getElementById("iframe-vrapp-mobile"))

或者在控制台中做一些等效的事情。使该元素 ID 实际存在并且它是一个 iframe。

我仍然不知道为什么它不起作用,但我不需要修复它 anymore.Now我没有更改我的 iframe 源,我在您加载时更改了我的网站它在 iphone 上。感谢您的关注。 :)