anchor

Auto-Scroll to next anchor at Mouse-wheel

蓝咒 提交于 2019-12-17 15:46:19
问题 I have 5 anchors on my html page. Is there any way that the page scrolls automatically to the next anchor (#) by a single Mouse-wheel scroll? Is there a way that it happens regardless of the anchor's name? just to the next anchor. 回答1: This works in Chrome, IE, Firefox, Opera, and Safari: (function() { var delay = false; $(document).on('mousewheel DOMMouseScroll', function(event) { event.preventDefault(); if(delay) return; delay = true; setTimeout(function(){delay = false},200) var wd = event

HTML anchor link - href and onclick both?

别来无恙 提交于 2019-12-17 15:12:45
问题 I want to author an anchor tag that executes some JavaScript and then proceeds to go wherever the href was taking it. Invoking a function that executes my JavaScript and then sets window.location or top.location to the href location doesn't work for me. So, imagine I have an element with id "Foo" on the page. I want to author an anchor similar to: <a href="#Foo" onclick="runMyFunction(); return false;">Do it!</a> When this is clicked, I want to execute runMyFunction and then jump the page to

How to prevent jump on an anchor click?

早过忘川 提交于 2019-12-17 11:07:07
问题 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/. 回答1: $(document).ready(function() { var hash = window.location.hash; var link = $('a'); $('a').click(function(e) { e.preventDefault(); hash = link.attr("href"); window

How to force fully download txt file on link?

拈花ヽ惹草 提交于 2019-12-17 10:59:17
问题 I have one simple text file and I want to download that file on any anchor tag link. But when I click on that link txt file shown me but not downloaded. I have try this code <html> <head> <title>File</title> </head> <body> <a href="test.txt">Click here</a> </body> </html> 回答1: Download file when clicking on the link (instead of navigating to the file): <a href="test.txt" download>Click here</a> Download file and rename it to mytextdocument.txt: <a href="test.txt" download="mytextdocument"

How do you make a div tag into a link

廉价感情. 提交于 2019-12-17 10:43:30
问题 How do you make a div tag into a link. I would like my entire div to be clickable. 回答1: 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 回答2: 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>

How to link html pages in same or different folders?

大城市里の小女人 提交于 2019-12-17 10:22:21
问题 How can I link to html pages if they are in same or different folders without writing full path? 回答1: Within the same folder, just use the file name: <a href="thefile.html">my link</a> Within the parent folder's directory: <a href="../thefile.html">my link</a> Within a sub-directory: <a href="subdir/thefile.html">my link</a> 回答2: In addition, if you want to refer to the root directory, you can use: / Which will refer to the root. So, let's say we're in a file that's nested within a few levels

Get anchor from URI

你说的曾经没有我的故事 提交于 2019-12-17 09:58:53
问题 I'm writing a JSP/Servlet and I'm trying to get the the anchor part of the URI e.g: blabla.rdf#mark How do I get my mark from my request? Obviously request.getParameter() doesn't work? Any help would be welcome. 回答1: This isn't possible as clients don't send the "anchor part" to the server As an example, here's the exact request that Chrome generated after submitting http://example.com/#foobar (recorded using Wireshark): GET / HTTP/1.1 Host: example.com Connection: keep-alive User-Agent:

javascript regex to extract anchor text and URL from anchor tags

若如初见. 提交于 2019-12-17 08:53:34
问题 I have a paragraph of text in a javascript variable called 'input_content' and that text contains multiple anchor tags/links. I would like to match all of the anchor tags and extract anchor text and URL, and put it into an array like (or similar to) this: Array ( [0] => Array ( [0] => <a href="http://yahoo.com">Yahoo</a> [1] => http://yahoo.com [2] => Yahoo ) [1] => Array ( [0] => <a href="http://google.com">Google</a> [1] => http://google.com [2] => Google ) ) I've taken a crack at it (http:

CodeIgniter - Correct way to link to another page in a view

你。 提交于 2019-12-17 08:48:48
问题 I was wondering if someone could tell me the correct way to link to another page from within a view. Is there a function for this or is it just the usual about Cheers, 回答1: I assume you are meaning "internally" within your application. you can create your own <a> tag and insert a url in the href like this <a href="<?php echo site_url('controller/function/uri') ?>">Link</a> OR you can use the URL helper this way to generate an <a> tag anchor(uri segments, text, attributes) So... to use it... <

CodeIgniter - Correct way to link to another page in a view

て烟熏妆下的殇ゞ 提交于 2019-12-17 08:47:59
问题 I was wondering if someone could tell me the correct way to link to another page from within a view. Is there a function for this or is it just the usual about Cheers, 回答1: I assume you are meaning "internally" within your application. you can create your own <a> tag and insert a url in the href like this <a href="<?php echo site_url('controller/function/uri') ?>">Link</a> OR you can use the URL helper this way to generate an <a> tag anchor(uri segments, text, attributes) So... to use it... <