转到HTML中另一页的div [英] Go to div of another page in HTML

查看:125
本文介绍了转到HTML中另一页的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从另一个页面转到特定页面的DIV。这可能吗?



我试过< a href =file.html#product> Hello< / a> $ b

但它只是转到 file.html#home



感谢



我在我的file.html文件夹中,重定向到file.html#home。

解决方案

使用HTML 5,您只需添加 id 属性添加到< div> ,其值 product 。这需要是页面内的唯一 id 属性(对于所有元素):

 < div id =product> 

请参阅 works draft

在HTML 4.01中,您需要在目标div上方使用<名称的锚标签,或者使用 id 属性:

 < a name =product>< / a> 
< div> ...

查看HTML 4.01 spec



<注意: name 属性 -4.10rel =noreferrer> deprecated 在XHTML 1.0规范中。



因此,这将是一个更好的选择,因为它适用于HTML 4.01,XHTML 1.0和HTML 5:

 < div id =product> 


I would like to go to the DIV of a particular page from a different page. Is that possible?

I tried <a href="file.html#product">Hello</a>

but it just goes to file.html#home

thanks

C.

I have in my file.html but it keeps getting redirected to file.html#home instead.

解决方案

With HTML 5, you need to simply add an id attribute to your <div> with a value of product. This needs to be a unique id attribute within the page (for all elements):

<div id="product">

See the working draft.

In HTML 4.01 you need to use an anchor tag with a name just above your target div, or any other element with an id attribute in the other page:

<a name="product"></a>
<div>...

See the HTML 4.01 spec.

Note: The name attribute has been deprecated in the XHTML 1.0 spec.

So, this would be a better option, as it would work for HTML 4.01, XHTML 1.0 and HTML 5:

<div id="product">

这篇关于转到HTML中另一页的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆