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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use div as iframe and add 'loading' message

    Hi,

    I'm creating a simle 'link collection' tool to use at work.

    The functionality right now is very basic. When first entering the side, theres a list of links and a dashboard. When clicking one of the links, they open in the iframe that the dashboard is in.

    Because of compatibility reasons, I wan't to use a div instead of an iframe to open the dashboard and links in.

    So instead of:
    Code:
    <a href="somelink.php" target="content">Link 1 </a>
    <iframe id="contet" src="dashboard.php"></iframe>
    ... I want a div that does the same thing - and that also has a loading message when loading dashboard.php.

    How can that be done using javascript? I only know very basic JS, and can't for the life of me get it to work with both a loading message and a "load link in div" function.

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,387
    Thanks
    32
    Thanked 288 Times in 282 Posts
    Quote Originally Posted by lleroy View Post
    Because of compatibility reasons, I wan't to use a div instead of an iframe to open the dashboard and links in.
    Could you identify the compatibility reasons?

    Quote Originally Posted by lleroy View Post
    So instead of:
    Code:
    <a href="somelink.php" target="content">Link 1 </a>
    <iframe id="contet" src="dashboard.php"></iframe>
    ... I want a div that does the same thing - and that also has a loading message when loading dashboard.php.

    How can that be done using javascript?
    Use the XMLHttpRequest object to request the file from the server, copy portions of the document, and insert them into your page. For security reasons, you'll need to have permissions from the server owning the page you're copying from if it isn't located on the same domain.

    XMLHttpRequest is complicated though; unless your "compatibility reasons" are compelling, I would recommend sticking with simple iframes or, better, eliminating iframes entirely by using server-side code inclusions.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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