Jump to content

[HTML & CSS & Javascript] hide the iframe at website load and show the iframe when button clicked

WillLTT

hey @WWicketi need help again with your code.

instead of necroposting im starting a new one.

 

this time i need help making your code in this forum posts ive come to the realizeation that i dont want the iframe to show at page load.

 

sumamary: i want to to hide atload and show it with the button

basically reverse what you did last time @WWicket

 

thanks for your time ?

(also anyone that has a clue what im  talking about are very very apprichiated to help me! ? )

Link to comment
Share on other sites

Link to post
Share on other sites

19 hours ago, WWicket said:

Just add 


  #iframe {
    display: none;
  }

to the style sheet.

new problem: it works, but the javascript hides the button it first, at first click. but its already hidden and due to that does need 3 clicks to show!

thanks for sticking around @WWicket? 

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, ughiwanthackintosh said:

new problem: it works, but the javascript hides the button it first, at first click. but its already hidden and due to that does need 3 clicks to show!

thanks for sticking around @WWicket? 

This is kind of messy and I'm not sure why it would be necessary-- probably some issue with loading orders-- but this seems to fix it:

 

remove from css:

#iframe {display:none;}

add to html in head: 

<script> document.addEventListener('DOMContentLoaded', (event) => {
      iframeHide();
  });</script>

add to js: 

function iframeHide() {
  var iframe = document.getElementById("iframe");
  iframe.style.display = "none";
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×