Iframe's src attribute

Discussion in 'HTML' started by Santel, Jan 17, 2007.

  1. Santel

    Santel Guest

    Hi,

    The below code doesn't display the txt file in IFrame.

    <iframe src=C:\Samples\Samples.txt></iframe>

    Only when I place the txt file inside my application directory, it
    works. Is this not possible to give cross-domain src in frames?
    Santel, Jan 17, 2007
    #1
    1. Advertising

  2. Santel

    Dylan Parry Guest

    Santel wrote:

    > Only when I place the txt file inside my application directory, it
    > works. Is this not possible to give cross-domain src in frames?


    Completely possible, but in your case you were referencing a file on
    your local system via an absolute URL (ie. c:\), and due to security
    settings in your browser you aren't able to do this. Otherwise any
    website could load the contents of any file on your system into an
    iframe, access it with Javascript and send the contents on to a
    malicious website. This would be a bad thing!

    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    Programming, n: A pastime similar to banging one's head
    against a wall, but with fewer opportunities for reward.
    Dylan Parry, Jan 17, 2007
    #2
    1. Advertising

  3. Santel

    Santel Guest

    Thanks for the reply Dylan.

    Accessing it with javascript will be getting problem, Isn't it? The
    file may be of any type like doc, htm etc; So any other options to do
    this?
    Santel, Jan 17, 2007
    #3
  4. Santel

    Dylan Parry Guest

    Santel wrote:

    [Linking to file on local file system]
    > So any other options to do this?


    You're always going to run into problems trying to link to files on your
    local system (ie. via a c:\ URI), so the only way you can really do it
    is to put the files you want to link to directly into your website's
    root directory (ie. where you put your HTML pages), or if you are able
    to, you can create a virtual directory that points to wherever your
    files are.

    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    Programming, n: A pastime similar to banging one's head
    against a wall, but with fewer opportunities for reward.
    Dylan Parry, Jan 17, 2007
    #4
  5. Santel

    Santel Guest

    Hi Dylan Parry,

    This is my actual requirement. I should allow the user to select any
    particular file from local disk (using open dialog) and display it in
    IFrame. So in this case, I couldn't restrict the user to select the
    file from a particular location. :(
    Santel, Jan 17, 2007
    #5
  6. Santel

    Dylan Parry Guest

    Santel wrote:

    > This is my actual requirement. I should allow the user to select any
    > particular file from local disk (using open dialog) and display it in
    > IFrame.


    Then using a webpage really isn't the best way of doing it. The security
    settings in almost every browser won't let you do what you are
    attempting. I would suggest that you either re-evaluate your needs, or
    look into developing a proper application that does what you are trying
    to achieve.

    --
    Dylan Parry
    http://electricfreedom.org | http://webpageworkshop.co.uk

    Programming, n: A pastime similar to banging one's head
    against a wall, but with fewer opportunities for reward.
    Dylan Parry, Jan 17, 2007
    #6
    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,076
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,064
  3. Replies:
    1
    Views:
    1,614
    Alex Hunsley
    Mar 23, 2007
  4. pheadxdll
    Replies:
    16
    Views:
    3,634
    Neredbojias
    Jun 6, 2007
  5. Soren Vejrum
    Replies:
    4
    Views:
    566
    Lasse Reichstein Nielsen
    Jul 5, 2003
Loading...

Share This Page