Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Popup message in iframe

    For the people that have iframe another website before: Have you iframe a website but when you try to leave the page a box would popup and says some thing like are you sure you want to leave the page, is there a way I can stop that?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Short, no there is no way to do this using an iframe from an external source. You don't control that code, you just give it a window to see it.
    Long answer, yes you can. But it requires you to fetch the source from the third party site and replace javascript. This can be performed using a library such as curl.

    All and all, as soon as you refer to HTML elements, this is not a PHP issue. And blocking the JS is also not a PHP issue. The only thing that PHP may do here is fetch all the code remotely and display it locally, but that means getting rid of the iframe completely since that now becomes useless to use.

  • #3
    New Coder
    Join Date
    Oct 2011
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Have this code here:



    (function() {
    var proxied = window.alert;
    window.alert = function() {
    // do something here
    return proxied.apply(this, arguments);
    };
    })();





    Would I be able to still do it with the code above, how could I use it for html?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I have no idea what you are asking. That is Javascript, not PHP. All I am saying is if you use an iframe you don't have control over the source of the requested link. You may be able to use javascript to block another javascript, but that would be a question to ask the client developers.

  • #5
    New Coder
    Join Date
    Oct 2011
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I'm trying to stop that "are you sure you want to leave" box from popping up all the time.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by bigvito19 View Post
    I'm trying to stop that "are you sure you want to leave" box from popping up all the time.
    I know what you want to do. And I'll say it again, if you use an iframe with an external source, its not your source code. You can see if there's a way in javascript to prevent such a popup, but from PHP world all you can do is read the source code from the remote and display it as your own. I recommend avoiding such a thing as often as you can as its easy to tag as a phishing site if you do so.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •