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 5 of 5
  1. #1
    Regular Coder Ranger56's Avatar
    Join Date
    Mar 2005
    Location
    Kent, WA.
    Posts
    783
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with loading in iframes.

    What's the javascript to make links that are clicked in the navbar, open in the iframe?
    Last edited by Ranger56; 03-22-2005 at 02:01 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Can be done without javascript, just plain HTML.

    <a href="thepage.html" target="nameOfTheIframe">link</a>

  • #3
    Regular Coder Ranger56's Avatar
    Join Date
    Mar 2005
    Location
    Kent, WA.
    Posts
    783
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For some reason, that wouldnt work for me, so I used,

    Code:
    		<script type="text/javascript">
    		function loadIframe(iframeName, url) {
      if ( window.frames[iframeName] ) {
        window.frames[iframeName].location = url;   
        return false;
      }
      else return true;
    }
    then
    Code:
    <A HREF="url" TITLE="title" onclick="return loadIframe('frame', this.href)"><IMG ALT="alt" SRC="img.url" WIDTH="" BORDER="" HEIGHT=""></A>
    Thanks anyways though.

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Although it sounds like it worked, you might want to find a non-javascript alternative, as some ppl have javascript disabled and it will make your site look nothing like what it looks like for someone with javascript enabled

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Quote Originally Posted by Ranger56
    For some reason, that wouldnt work for me, so I used,
    It should work. Did you specify the name (not the id) of the iframe in the target?

    As Scootertaj mentioned, you should provide a non-javascript alternative as it can be disabled. And my suggested solution is the answer.


  •  

    Posting Permissions

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