PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 1, 2022

[FIXED] How To hide button when pages open in iframe?

 December 01, 2022     html, iframe, javascript, jquery     No comments   

Issue

I want to display: none , the save button , when my html page opens in iframe.

How can I do it ?

This link might help me , but I did not understand this link.

iframe code

<HTML>  
 <BODY>
   <iframe id="myiFrame" src="file:///C:/Users/Prashant/Desktop/test.html"> </iframe>
  </BODY>
</HTML>

test.html

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML>
   <BODY>
         <button id="hideInIframe" >save</button>
         <button id="getData" >get</button>
   </BODY>
 </HTML>

Solution

Use this:

if ( window.self !== window.top ) {
// you're in an iframe
}

Finally:

if ( window.self !== window.top ) {
  $("#hideInIframe").css('display','none');
}

This way, each time test.html is in an iframe (of yours, or of anyone else), the save button is hide.



Answered By - 3pic
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing