Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Anybody know how to make a read-only Iframe?

Anybody know how to make a read-only Iframe?

Scheduled Pinned Locked Moved Web Development
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darrell Long
    wrote on last edited by
    #1

    I want to include some dynamic content from another site, but I want to restrict the user from clicking any of the links on that site so they can't navigate away from my page. Most of the things I have tried in terms of capturing mouse events to prevent navigation are ignored when the mouse is over the IFrame. Thanks in advance.

    L 1 Reply Last reply
    0
    • D Darrell Long

      I want to include some dynamic content from another site, but I want to restrict the user from clicking any of the links on that site so they can't navigate away from my page. Most of the things I have tried in terms of capturing mouse events to prevent navigation are ignored when the mouse is over the IFrame. Thanks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      yes, definitely you can make iframe read only..

      //Paste the code inside the entity onload event box

      var IFRAME_Test;
      var IFRAME_Test_Disable_Message = "IFRAME Disabled...";

      function OnCrmPageLoad() {
      //Reference the IFRAME
      IFRAME_Test = document.all.IFRAME_Test;
      //Bind to its ready state event (wait until the iframe is fully loaded)
      IFRAME_Test.attachEvent( "onreadystatechange" , OnTestIframeReady );
      }

      function OnTestIframeReady() {
      if( IFRAME_Test.readyState != "complete" )
      return;
      //Override the onmousedown event
      IFRAME_Test.contentWindow.document.onmousedown = OnTestIframeMouseDown;
      }

      function OnTestIframeMouseDown() {
      alert( IFRAME_Test_Disable_Message );
      /* or use */
      //the window is put beyond the user's desktop and is immediately closed
      var stubWin = window.open(‘about:blank’,’’,’ toolbars=0,width=100,height=100,top=10000,left=10000’);
      stubWin.close();
      return false;
      }

      //Entry point
      OnCrmPageLoad();

      HTH

      Jinal Desai - LIVE Experience is mother of sage....

      D 1 Reply Last reply
      0
      • L Lost User

        yes, definitely you can make iframe read only..

        //Paste the code inside the entity onload event box

        var IFRAME_Test;
        var IFRAME_Test_Disable_Message = "IFRAME Disabled...";

        function OnCrmPageLoad() {
        //Reference the IFRAME
        IFRAME_Test = document.all.IFRAME_Test;
        //Bind to its ready state event (wait until the iframe is fully loaded)
        IFRAME_Test.attachEvent( "onreadystatechange" , OnTestIframeReady );
        }

        function OnTestIframeReady() {
        if( IFRAME_Test.readyState != "complete" )
        return;
        //Override the onmousedown event
        IFRAME_Test.contentWindow.document.onmousedown = OnTestIframeMouseDown;
        }

        function OnTestIframeMouseDown() {
        alert( IFRAME_Test_Disable_Message );
        /* or use */
        //the window is put beyond the user's desktop and is immediately closed
        var stubWin = window.open(‘about:blank’,’’,’ toolbars=0,width=100,height=100,top=10000,left=10000’);
        stubWin.close();
        return false;
        }

        //Entry point
        OnCrmPageLoad();

        HTH

        Jinal Desai - LIVE Experience is mother of sage....

        D Offline
        D Offline
        Darrell Long
        wrote on last edited by
        #3

        Thanks, I've seen variants of that code segment on the web and they just seem to be ignored. I think I am not putting the start code in the right place and it is not being executed. I have also tried putting the OnCrmPageLoad() function call in the onload event for the iframe. Alot of these examples refer to Microsoft CRM and I don't think I am using that. I am just trying to do this with HTML and Javascript. Here is what I have now.

        <HTML>
        <HEAD>

        <script language="javascript" type="text/javascript">
        //Paste the code inside the entity onload event box

        var IFRAME_Test;
        var IFRAME_Test_Disable_Message = "IFRAME Disabled...";

        function OnCrmPageLoad() {
        //Reference the IFRAME
        IFRAME_Test = document.all.IFRAME_Test;
        //Bind to its ready state event (wait until the iframe is fully loaded)
        IFRAME_Test.attachEvent( "onreadystatechange" , OnTestIframeReady );
        }

        function OnTestIframeReady() {
        if( IFRAME_Test.readyState != "complete" )
        return;
        //Override the onmousedown event
        IFRAME_Test.contentWindow.document.onmousedown = OnTestIframeMouseDown;
        }

        function OnTestIframeMouseDown() {
        alert( IFRAME_Test_Disable_Message );
        /* or use */
        //the window is put beyond the user's desktop and is immediately closed
        var stubWin = window.open(‘about:blank’,’’,’ toolbars=0,width=100,height=100,top=10000,left=10000’);
        stubWin.close();
        return false;
        }

        //Entry point
        OnCrmPageLoad();

        </script>

        </HEAD>
        &t;body>

        <iframe id="IFRAME_Test" frameborder="1" width="800" style="z-index:1; height:400;" src="http://weathernow.denverpost.com/"></iframe>

        </body>
        </HTML>

        Thanks for the help.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups