Trapping navigation errors from IFRAME's src

Discussion in 'Javascript' started by Phlip, Jan 7, 2007.

  1. Phlip

    Phlip Guest

    Javascripters:

    When I hit the following in IE, it puts up an error message "Cannot find
    file ...bad%20url... Make sure the path" is correct etc. When I hit it in
    Firefox I get no error. (Ironic because Firebug is installed...):

    <iframe src='bad url' onerror='alert("yo");' />

    What I _want_ to happen is my onerror event fires. I naturally intend to
    upgrade the alert("yo"); part into something more germane and
    application-specific.

    Some documentation out there says IFRAMEs have onerrors and some don't say
    they do...

    Okay, let's kick this up a notch:

    <script src="http://.../prototype.js" type="text/javascript"></script>

    <iframe id='fry_me' onerror='alert("yo");' />

    <script>
    $('fry_me').src = 'bad url';
    <script>

    Now neither IE nor Firefox produce any error message of any kind. If either
    had thrown an error, I could naturally 'try' to 'catch' it in the
    Javascript.

    Taking out the onerror, and adding a try/catch, also don't work.

    Ordinarily, the answer to one of these IFRAME attack questions is to upgrade
    the source the IFRAME calls. And of course I can't do that because the error
    happens before the IFRAME has a page to evaluate.

    I need the IFRAME to respond to URLs which the user supplies, so I need a
    healthy and application-specific error path if the URL is wrong. Not the
    default irritation -- or the absense thereof!

    So how to beat healthy error information out of an IFRAME's src attribute?

    --
    Phlip
    http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
     
    Phlip, Jan 7, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,140
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,114
  3. Replies:
    1
    Views:
    1,639
    Alex Hunsley
    Mar 23, 2007
  4. Soren Vejrum
    Replies:
    4
    Views:
    672
    Lasse Reichstein Nielsen
    Jul 5, 2003
  5. Bwig Zomberi

    Trapping errors inside IFRAME

    Bwig Zomberi, Sep 24, 2011, in forum: Javascript
    Replies:
    3
    Views:
    673
    Bwig Zomberi
    Sep 28, 2011
Loading...

Share This Page