anchor

How to enable or disable an anchor using jQuery?

戏子无情 提交于 2019-11-26 01:46:54
问题 How to enable or disable an anchor using jQuery? 回答1: To prevent an anchor from following the specified href , I would suggest using preventDefault(): // jQuery 1.7+ $(function () { $('a.something').on("click", function (e) { e.preventDefault(); }); }); // jQuery < 1.7 $(function () { $('a.something').click(function (e) { e.preventDefault(); }); // or $('a.something').bind("click", function (e) { e.preventDefault(); }); }); See: http://docs.jquery.com/Events/jQuery.Event#event.preventDefault

How to open link in new tab on html?

好久不见. 提交于 2019-11-26 01:31:44
问题 I\'m working on an HTML project, and I can\'t find out how to open a link in a new tab without javascript. I already know that <a href=\"http://www.WEBSITE_NAME.com\"></a> opens the link in same tab. Any ideas how to make it open in a new one? 回答1: Set the 'target' attribute of the link to _blank : <a href="#" target="_blank" rel="noopener noreferrer">Link</a> Edit: for other examples, see here: http://www.w3schools.com/tags/att_a_target.asp (Note: I previously suggested blank instead of

How to handle anchor hash linking in AngularJS

这一生的挚爱 提交于 2019-11-26 01:25:25
问题 Do any of you know how to nicely handle anchor hash linking in AngularJS ? I have the following markup for a simple FAQ-page <a href=\"#faq-1\">Question 1</a> <a href=\"#faq-2\">Question 2</a> <a href=\"#faq-3\">Question 3</a> <h3 id=\"faq-1\">Question 1</h3> <h3 id=\"faq-2\">Question 2</h3> <h3 id=\"fa1-3\">Question 3</h3> When clicking on any of the above links AngularJS intercepts and routes me to a completely different page (in my case, a 404-page as there are no routes matching the links

How to apply Hovering on html area tag?

落花浮王杯 提交于 2019-11-26 00:33:39
问题 I am trying to hover the area tag of HTML. I tried this in CSS: area:hover { border:1px solid black; } This is the HTML on which it should be applied. <!-- This imagemap inserted by Gwyn\'s Imagemap Selector http://gwynethllewelyn.net/gwyns-imagemap-selector/ --> <img src=\'http://dailyaeen.com.pk/epaper/wp-content/uploads/2012/09/27+Sep+2012-1.jpg?1349003469874\' usemap=\'#imgmap_css_container_imgmap201293016112\' class=\'imgmap_css_container\' title=\'imgmap201293016112\' alt=\

How to scroll up or down the page to an anchor using jQuery?

耗尽温柔 提交于 2019-11-26 00:27:15
问题 I\'m looking for a way to include a slide effect for when you click a link to a local anchor either up or down the page. I\'d like something where you have a link like so: <a href=\"#nameofdivetc\">link text, img etc.</a> perhaps with a class added so you know you want this link to be a sliding link: <a href=\"#nameofdivetc\" class=\"sliding-link\">link text, img etc.</a> Then if this link is clicked, the page slides up or down to the required place (could be a div, heading, top of page etc).

using href links inside <option> tag

与世无争的帅哥 提交于 2019-11-25 23:36:38
问题 I have the following HTML code: <select name=\"forma\"> <option value=\"Home\">Home</option> <option value=\"Contact\">Contact</option> <option value=\"Sitemap\">Sitemap</option> </select> How can I make Home , Contact and Sitemap values as links? I used the following code and as I expected it didn\'t work: <select name=\"forma\"> <option value=\"Home\"><a href=\"home.php\">Home</a></option> <option value=\"Contact\"><a href=\"contact.php\">Contact</a></option> <option value=\"Sitemap\"><a

How to scroll HTML page to given anchor?

房东的猫 提交于 2019-11-25 23:21:17
问题 I’d like to make the browser to scroll the page to a given anchor, just by using JavaScript. I have specified a name or id attribute in my HTML code: <a name=\"anchorName\">..</a> or <h1 id=\"anchorName2\">..</h1> I’d like to get the same effect as you’d get by navigating to http://server.com/path#anchorName . The page should be scrolled so that the anchor is near the top of the visible part of the page. 回答1: function scrollTo(hash) { location.hash = "#" + hash; } No jQuery required at all!

Get fragment (value after hash &#39;#&#39;) from a URL in php

本小妞迷上赌 提交于 2019-11-25 22:40:40
问题 How can I get the fragment (value after hash \'#\') from a URL in php? Say from http://domain.com/site/gallery/1#photo45 I want photo45 回答1: If you want to get the value after the hash mark or anchor as shown in a user's browser: This isn't possible with "standard" HTTP as this value is never sent to the server (hence it won't be available in $_SERVER["REQUEST_URI"] or similar predefined variables). You would need some sort of JavaScript magic on the client side, e.g. to include this value as

Make a div into a link

强颜欢笑 提交于 2019-11-25 22:36:14
问题 I have a <div> block with some fancy visual content that I don\'t want to change. I want to make it a clickable link. I\'m looking for something like <a href=\"…\"><div> … </div></a> , but that is valid XHTML 1.1. 回答1: Came here in the hope of finding a better solution that mine, but I don't like any of the ones on offer here. I think some of you have misunderstood the question. The OP wants to make a div full of content behave like a link. One example of this would be facebook ads - if you

How can I create a link to a local file on a locally-run web page?

淺唱寂寞╮ 提交于 2019-11-25 22:35:59
问题 I\'d like to have an html file that organizes certain files scattered throughout my hard drive. For example, I have two files that I would link to: C:\\Programs\\sort.mw C:\\Videos\\lecture.mp4 The problem is that I\'d like the links to function as a shortcut to the file. I\'ve tried the following: <a href=\"C:\\Programs\\sort.mw\">Link 1</a> <a href=\"C:\\Videos\\lecture.mp4\">Link 2</a> ... but the first link does nothing and the second link opens the file in Chrome, not VLC. My questions