I have a web page that is a table of contents and the page navigation is not working. Here is the html:
<a name="top_of_page">Create Account</a>
top
When i click on the top of page link nothing happens. Am i doing something wrong? Thanks for any help in advance.
name is not the correct attribute to use. Use id instead.
<a id="top_of_page">Create Account</a>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
top
Related
I have an anchor in a webpage I'm building like this:
<a id="Equity"> </a>
In IE11, the link https://example.com/myPage.html#Equity brings me to the anchor location for a second, and then back to the top of the page. The anchor works correctly with Chrome and Firefox.
I have also tried these, with the same result:
<a name="Equity"> </a>
<div id="Equity"> </div>
<a id="Equity">Some text</a>
Anyone know what could be happening? I've scoured the web without success. I would very much appreciate any help.
Edit: I've discovered that this issue only occurs the first time the URL is loaded in a window/tab. If you refresh the page, it jumps to the anchor correctly, and does not return to the top of the page.
I have an index.html that includes:
<li>
<a href="imprint.html#imprint-link">
<div class="main-menu-title">IMPRINT</div>
</a>
</li>
When I click on this item another html file (imprint.html) is loaded, but when I click on Home, which includes the following code to go back to index.html, it doesn't work!
<a href="#index-link">
<div class="main-menu-title">HOME</div>
</a>
What is wrong here?
Update 1: When hovering the mouse over the link I get:
try using this code :
<a href="index.html">
<div class="main-menu-title">HOME</div>
</a>
inplace of :
<a href="#index-link">
<div class="main-menu-title">HOME</div>
</a>
To answer your original question.
What's wrong here?
As a couple kind folks already commented and one person already provided a nice solution, clicking on your original link
href="#index-link"
while you are on the imprint.html page will not take you to your index.html page. Why? Because
<a href="#index-link">
<div class="main-menu-title">HOME</div>
</a>
is saying, "Take me to an element on the current page (imprint.html) that has an ID of 'index-link'. If there is no element with and ID set to index-link, on the imprint.html page, nothing will happen. And, you will stay on the current page because you didn't specify an URL outside of the current page, which is still imprint.html.
So, with that current setup, you will not get to see index.html.
I try to make a duplicate of the share button on the following site (it's at the bottom):
WARNING! THE IMAGES ON THIS SITE CAN BE VERY DISTURBING!!!
http://www.bbc.co.uk/news/special/2014/newsspec_8702/index.html
If I click from there it looks like this:
If I copy the code:
<a href="https://www.facebook.com/dialog/feed?app_id=58567469885&redirect_uri=http%3A%2F%2Fwww.bbc.co.uk%2Fmodules%2Fsharetools%2Fcallback%3Fst_cb%3Dfacebook%23state%3Dfeed&display=popup&link=http://www.bbc.co.uk/news/magazine-29205427&name=Voices%20from%20the%20mall%20-%20remembering%20the%20first%20terrifying%20hours%20of%20the%20Westgate%20attack%20a%20year%20ago%2C%20via%20%40BBCNewsMagazine&description=Shared%20via%20BBC%20News&picture=http://newsimg.bbc.co.uk/media/images/67373000/jpg/_67373987_09f1654a-e583-4b5f-bfc4-f05850c6d3ce.jpg" target="_blank"><span>Facebook</span>
</a>
And put it in a html or jsfiddle:
https://jsfiddle.net/clankill3r/6oufc1pL/
Then instead of a popup I get a new window and the image is gone:
Why is that? And how can I change this behavior.
edit:
If I click the popup on the original site the link changes to this for some strange reason:
https://www.facebook.com/dialog/feed?app_id=58567469885&redirect_uri=http%3A%2F%2Fwww.bbc.co.uk%2Fmodules%2Fsharetools%2Fcallback%3Fst_cb%3Dfacebook%23state%3Dfeed&display=popup&link=www.bbc.co.uk/news/magazine-29205427&name=Voices%20from%20the%20mall%20-%20remembering%20the%20first%20terrifying%20hours%20of%20the%20Westgate%20attack%20a%20year%20ago%2C%20via%20%40BBCNewsMagazine&description=Shared%20via%20BBC%20News%20Magazine&picture=http://www.bbc.co.uk/news/special/2014/newsspec_8702/static/img/fb.png
Change the picture= to image= like this:
<a href="https://www.facebook.com/dialog/feed?app_id=58567469885&redirect_uri=http%3A%2F%2Fwww.bbc.co.uk%2Fmodules%2Fsharetools%2Fcallback%3Fst_cb%3Dfacebook%23state%3Dfeed&display=popup&link=http://www.bbc.co.uk/news/magazine-29205427&name=Voices%20from%20the%20mall%20-%20remembering%20the%20first%20terrifying%20hours%20of%20the%20Westgate%20attack%20a%20year%20ago%2C%20via%20%40BBCNewsMagazine&description=Shared%20via%20BBC%20News&image=http://newsimg.bbc.co.uk/media/images/67373000/jpg/_67373987_09f1654a-e583-4b5f-bfc4-f05850c6d3ce.jpg" target="_blank"><span>Facebook</span>
</a>
Does this work for you?
How I can give anchor link for a div of external file. For example I am in home page, now I want to go to div with id name "Electronics" in products.html page.
I have tried with doing some thing like
<a href="products.html#Electronics" />
But it is not working properly. If some one know alternative way please let me know.
Thanks in advance.
Your URL should like this..
Link
in your case it should be
<a href="products.html/#Electronics" />
I hope it helps you
DEMO: http://jsfiddle.net/ZRLB5/
Here my site: viettech-ca. com
My codes:
<div class="wrap footer-nav mgt35">
<ul>
<li>Về chúng tôi</li>
<li>Đại lý</li>
<li>Liên hệ</li>
<li>Điều kiện & Điều khoản</li>
<!-- <li>--><!--</li>--></ul>
<div><a class="go-top" href="#">Lên đầu trang</a></div>
</div>
go-top works, but it redirected me to the top of the homepage instead of the top of the current page.. Please show problem
since you also have javascript:
JS:
function scroll2Top(){
scroll(0,0);
}
HTML
<a class="go-top" onclick="scroll2Top();return false;">Lên đầu trang</a>
I'm assuming you want to set up a 'Go to top' link in your page that takes the user back to the top of the page.
You do this with anchor tags where you would usually define it at the top of your code and then reference to it when required.
Code at top of html:
<body>
<a name="top"></a>
...
Then your 'href' link would be as follows:
<div><a class="go-top" href="#top">Lên đầu trang</a></div>
If you leave out the top anchor name (name="top") it will still work, but this is bad practice because whats happening is that the page can't find the '#top' reference, it scrolls to the top anyway but because is can't find the link.