简体   繁体   English

如何阻止Wordpress页面跳转/滚动到iframe?

[英]How do I stop a Wordpress page from jumping/scrolling to an iframe?

I have a Wordpress site, and a small iframe towards the bottom of the page. 我有一个Wordpress网站,并且页面底部有一个小的iframe。 Whenever the page loads it jumps to where the iframe is. 每当页面加载时,它都会跳转到iframe所在的位置。

I've tried hiding the element and adding a javascript function 我试图隐藏元素并添加javascript函数

HTML 的HTML

<iframe id="iframe_wrapper" src="link-here" frameborder="0"
scroll="no" onload="showOnLoad();"></iframe>

CSS 的CSS

#iframe_wrapper {display:none;}

JS JS

function showOnLoad() {
document.getElementById("iframe_wrapper").style.display = 'block';
}

The iframe appears, but it dind't fix the jumping issue. iframe出现了,但是并没有解决跳跃问题。

plz add "opacity:0" instead of "display:none".. check the below code.. 请添加“ opacity:0”而不是“ display:none” ..检查以下代码。

css 的CSS

#iframe_wrapper {
  opacity:0;
}

js js

function showOnLoad() {
  document.getElementById("iframe_wrapper").style.opacity= '1';
}

you can set the height to 1px 您可以将高度设置为1px

#iframe_wrapper {
  height:1px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何停止iframe滚动直到它完全在页面上? (里面的图片) - How do I stop an iframe from scrolling until it's entirely on the page? (pictures inside) 如何通过编辑引用的页面来禁用 iframe 滚动? - How do I disable an iframe from scrolling by editing the referenced page? 如何阻止JS驱动的全页滚动从跳转到开始/结束 - How do I stop a JS driven full page scroll from jumping to the start/end 阻止父页面向下滚动到iframe - stop parent page from scrolling down to iframe 将上方的div更改为fixed时,如何阻止继承位置的元素跳出页面? - How do I stop an inheritly positioned element from jumping up page when I change the div above it to fixed? 当在PHP中单击按钮时,如何停止页面滚动到顶部? - How do i stop a page from scrolling to the top when button clicked in php? 单击触发 JavaScript 的链接时,如何阻止网页滚动到顶部? - How do I stop a web page from scrolling to the top when a link is clicked that triggers JavaScript? 如何在页面加载中阻止两个轮播自动滚动? - How do I on page load stop two carousels from auto scrolling? 调用JavaScript函数时,如何阻止网页滚动到顶部? - How do I stop a web page from scrolling to the top when calling a JavaScript function? 如何在滚动时停止跳跃 Position 固定元素 - How to Stop Jumping Position fixed element on scrolling
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM