Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

iframe - Embedding html page and removing divs

Good Morning,

I am in need of assistance, I am not a programmer and I am venturing to create a website for my company, I am having a lot of difficulty in the following question:

  • I need to incorporate a news page, but I only need the news fields, that is, if I import with the iframe it brings the entire page with a header and footer, I need to bring the page without a header and footer, for that I need remove or hide some divs in the iframe, when I try to do that I can't because of the security error.

Does anyone have any solution to solve this problem?

Thank you in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't know your code, so i can't know, what that security error is...

You can use javascript to remove elements in iframe, and this shouldn't throw any error...

content of html with iframe...

<script>
   let newsIframe = document.getElementById("newspage");
   let newsHeader = iframe.contentWindow.document.getElementById("header");
   newsHeader.style.display = "none"; 
   let newsFooter = iframe.contentWindow.document.getElementById("footer");
   newsFooter.style.display = "none"; 
</script>

more content...

That script tag with code must be after your <iframe>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...