views:

352

answers:

6

I have 3 links that represent the content for one iFrame in my page. When you click each link, it'll reload the contents of that iFrame without reloading the page.

How do i set one link to be active/selected by default, cause what's happening now is the page loads, but still i have to click on the link before the content of the iFrame loads?

here's my code:

            <div id="tabs">
                <div id="overview">
                     <a id="overviewtab" target="tabsa" href="toframe.html">Overviews</a>
                </div>
                <div id="gallery">
                     <a target="tabsa" href="tawagpinoygallery.html">Gallery</a>
                </div>
                <div id="reviews">
                     <a target="tabsa" href="trframe.html">Reviews</a>
                </div>
            </div>
            <div id="tabs-1">
                <!--<div id="scroller">-->
                <iframe name= "tabsa" width="95%" height="100%" frameborder="0"></iframe>
            </div>

thanks so much!! :)

+3  A: 

You simply set the src attribute of the iframe to the desired url:

<div id="tabs-1">
<!--<div id="scroller">-->
  <iframe src="toframe.html" name= "tabsa" width="95%" height="100%" frameborder="0"></iframe>
</div>
Sani Huttunen
Damn, you got there first!
Codesleuth
this worked like a charm!! thanks to everyone who helped!! you guys are amazing!! :)P.S. as a way for me to say thank you, please e-mail me at lauranoel at me dot com if you guys need help with graphic/iPhone UI design. :)
laura
A: 

If you have a fixed page to start with, change the iframe code to:

<iframe src="toframe.html" name= "tabsa" width="95%" height="100%" frameborder="0"></iframe>
Codesleuth
A: 

The simplest is to set the src attribute of your iframe to the default content:

<!-- default content is toframe.html -->
<iframe name="tabsa"
        width="95%"
        height="100%"
        frameborder="0"
        src="toframe.html"
></iframe>
slebetman
+1  A: 

You can click on a link using JavaScript, e.g. in the onload attribute of <body>.

A better solution, though, would be to just load the default document into the iframe right away by specifying <iframe src="toframe.html" ...>

RegDwight
A: 

Can't you set the value of the iframe's href attribute to the default link? This wouldn't make the link 'active' per say but it would load something when you first log in and allow the frame to load the other links as well.

You might also be able to use javascript to 'click' the link once the window is loaded. I believe this code would look something like function init() = { a.click(); } window.onload = init();

However I'm forced to ask why you would want to make such a sparse page so complicated with the iframe interaction; most people nowadays have a fast enough internet connection that we don't need to code like that. Even if you are targetting low-bandwidth markets the page doesn't seem to have enough content to warrant framing.

C Bauer
A: 

new problem:

how do i set the image of my link to change when it's active?

here's a sample of my css code:

#gallery a { 
text-indent: -9999px; 
padding-top: 40px; 
background: url(../images/GalleryTab.png) no-repeat; 
height: 51px; width: 123px; position: absolute; z-index: 2; 
} 

#gallery a:active, a:hover { 
text-indent: -9999px; 
padding-top: 40px; 
background: url(../images/galleryoverview.png) no-repeat; 
height: 51px; 
width: 123px; 
position: absolute; 
z-index: 2; 
} 

it doesn't seem to work.. :o i only see the change in image when i hold the mouse down on the link, but when i click it, the image remains the same as if it wasn't the active tab. :o thanks!!

laura
Hi Laura. You’ll want to add that as a new question, rather than an answer on your existing question. It’ll get much more attention that way (and thus answers).
Paul D. Waite