简体   繁体   English

将链接默认设置为活动

[英]Set Link as Active by Default

I have 3 links that represent the content for one iFrame in my page. 我有3个链接,它们表示页面中一个iFrame的内容。 When you click each link, it'll reload the contents of that iFrame without reloading the page. 当您单击每个链接时,它将重新加载该iFrame的内容,而无需重新加载页面。

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? 如何将一个链接设置为默认处于活动状态/选中状态,导致现在正在加载页面,但仍然需要在iFrame内容加载之前单击链接?

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!! 非常感谢!! :) :)

You simply set the src attribute of the iframe to the desired url: 您只需将iframe的src属性设置为所需的网址即可:

<div id="tabs-1">
<!--<div id="scroller">-->
  <iframe src="toframe.html" name= "tabsa" width="95%" height="100%" frameborder="0"></iframe>
</div>

You can click on a link using JavaScript, eg in the onload attribute of <body> . 您可以使用JavaScript单击链接,例如,在<body>onload属性中。

A better solution, though, would be to just load the default document into the iframe right away by specifying <iframe src="toframe.html" ...> 不过,更好的解决方案是通过指定<iframe src="toframe.html" ...>来将默认文档立即加载到iframe中

如果您有固定的页面开始,请将iframe代码更改为:

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

The simplest is to set the src attribute of your iframe to the default content: 最简单的方法是将iframe的src属性设置为默认内容:

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

Can't you set the value of the iframe's href attribute to the default link? 您不能将iframe的href属性的值设置为默认链接吗? 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. 加载窗口后,您也许还可以使用javascript“单击”链接。 I believe this code would look something like function init() = { a.click(); 我相信这段代码看起来像函数init()= {a.click(); } window.onload = init(); } 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; 但是,我不得不问为什么要通过iframe交互使如此稀疏的页面变得如此复杂;为什么? 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. 即使您瞄准的是低带宽市场,该页面似乎也没有足够的内容来保证取景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM