anchor

Javascript: How to truly reload a site with an anchor tag?

旧街凉风 提交于 2019-11-27 15:34:59
问题 Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site mysite.htm and triggering the reload thru location.href won't reload the page but jump to the anchor named within the URL. I need a mechanism to truly reload the page. Any ideas? PS: I tried location's other methods but none of them does the trick :( EDIT Don't hang on the filetype htm . I'd need it for dynamic sites as well. 回答1: After you set the specified URL into location, issue

Why Doesn't This CSS Transition Work On SVG Inside an Anchor

孤街浪徒 提交于 2019-11-27 15:15:44
问题 I'm trying to transition the fill and path of an embedded SVG object, however this doesn't seem to work (Code Pen here): The SVG: <a class="simple-link svg-link" href=""> Some Text <svg version="1.1" id="next-page-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 25 25" enable-background="new 0 0 25 25" xml:space="preserve" preserveAspectRatio="xMinYMin meet"> <circle class="the-background" cx="12.5" cy="12.5" r="12.5"/> <g> <path

Scroll to anchor with fixed header, content hidden behind header, margin and top padding not working

爱⌒轻易说出口 提交于 2019-11-27 15:06:35
问题 I'm using smoothscroll.js to navigate my site. It stops on the correct anchor in Firefox, however in Chrome it passes the point on the first click of the link, and pushes the content to the top, hiding the content behind the page. then if you click it again, it aligns correctly. I've seen the problems on other sites as well. Curious to see if others have the same problem. Chrome seems to ignore any top padding or margin or positioning (example: top:20%;). 回答1: SOLVED: http://nicolasgallagher

Why do page anchors sometimes miss?

岁酱吖の 提交于 2019-11-27 14:39:40
问题 On an HTML page, a link like this: <a href="#pagelocation">Location on Page</a> ...should navigate to this spot on the page: <a name="pagelocation"> But in my experience, it sometimes misses - especially when linking from another page (like <a href="somepage.html#pagelocation"> ). By "misses," I mean it scrolls to the wrong spot on the page - maybe close, maybe not. Normally, the target location ends up at the top of the screen. I know this can fail if there's not enough room below the anchor

How to simulate anchor link click

孤人 提交于 2019-11-27 14:27:29
问题 I'm trying to trigger a link click for .jquery. Does someone know why the following doesn't work. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>test</title> </head> <body> <div> <a id="google_link" href="http://google.com" target="_blank">click to go to google</a> </div> <div id="google_link_proxy">click here to do the same as the link above</div> <script type="text/javascript"> $("#google_link_proxy")

How to prevent jump on an anchor click?

纵饮孤独 提交于 2019-11-27 14:07:40
I use e.preventDefault(); to disable default anchor behaviour. Is there a way to prevent only jump action to a target on click? I tried: var hash = window.location.hash; var link = $('a'); $('a').click(function() { e.preventDefault(); hash = "#"+link.attr("href"); }); But it doesn't work: http://jsfiddle.net/ynts/LgcmB/ . $(document).ready(function() { var hash = window.location.hash; var link = $('a'); $('a').click(function(e) { e.preventDefault(); hash = link.attr("href"); window.location = hash; }); }); You also have to specify event argument in the function. By naming it as e or event and

CSS- Highlight a div when the id is linked to using an anchor?

白昼怎懂夜的黑 提交于 2019-11-27 13:24:09
问题 What I am attempting to do is to highlight a div with a certain id, when It has been referred to by an anchor on another page IE: User clicks link href="qw.html#test" , when the page is loaded, then the div with the id="test" is highlighted so that the user can see it clearly. I'm sure that I've seen a CSS3 example where a div is highlighted if it was linked to. Or was it JavaScript? 回答1: You need to use the :target pseudo-class: :target { background-color: #ffa; } JS Fiddle demo. 回答2: You

What's the right way to define an anchor tag in rails?

柔情痞子 提交于 2019-11-27 13:00:41
问题 It's obvious from the documentation (and google) how to generate a link with a segment e.g. podcast/5#comments . You just pass a value for :anchor to link_to . My concern is about the much simpler task of generating the <a name="comments">Comments</a> tag i.e. the destination of the first link. I've tried the following, and although they seemed to work, the markup was not what I expected: link_to "Comments", :name => "comments" link_to "Comments", :anchor => "comments" I think I'm missing

How do you make a div tag into a link

六月ゝ 毕业季﹏ 提交于 2019-11-27 12:28:55
How do you make a div tag into a link. I would like my entire div to be clickable. JS: <div onclick="location.href='url'">content</div> jQuery: $("div").click(function(){ window.location=$(this).find("a").attr("href"); return false; }); Make sure to use cursor:pointer for these DIVs If you have to set your anchor tag inside the div, you can also use CSS to set the anchor to fill the div via display:block. As such: <div style="height: 80px"><a href="#" style="display: block">Text</a></div> Now when the user floats their cursor in that div the anchor tag will fill the div. Rael Gugelmin Cunha If

hash in anchor tags

混江龙づ霸主 提交于 2019-11-27 12:07:58
How do I load a page and get it to open at a certain location of the loaded page? For example, lets say I have page1.html , which has 3 links <a href="page2.html#1">1</a> <a href="page2.html#2">2</a> <a href="page2.html#3">3</a> on page2.html , I have those links on the page also, i.e. <a href="page3.html#1">1</a> <a href="page3.html#2">2</a> <a href="page3.html#3">3</a> but when I click on the #2 or #3 link from page1.html , they always open at the top of the page, even though #2 and #3 are off the screen on page2.html which need to be scrolled down to to be seen. Not sure what I am doing