href

javascript:; vs javascript:void(0);

こ雲淡風輕ζ 提交于 2019-12-18 11:04:27
问题 I would like to know what is the difference between javascript:; and javascript:void(0); if I use them in href attribure for a anchor (link) <a href="javascript:;" onclick="DoSomething();">Link</a> <a href="javascript:void(0);" onclick="DoSomething();">Link</a> I see them acting the same on all browsers but what is the technical difference? Regards, Magdy 回答1: One runs JavaScript that has no statements, the other runs JavaScript that evaluates the statement 0 and then returns undefined .

Alternatives for using “#” in href attribute [duplicate]

巧了我就是萌 提交于 2019-12-18 10:47:09
问题 This question already has answers here : Closed 10 years ago . Possible Duplicate: Href for Javascript links: “#” or “javascript:void(0)”? The <a> tag is used to create hyperlinks but in this age of jQuery and Ajax we are using it to load HTML into <div> s in the same page as the <a> tags. That said, we set the href atribute as href="#" , using or rather abusing the # character as a placeholder along with some undesirable side effects like the URL getting appended with the # character. And if

link with href=“#” scrolls page to top when used with jquery slidetoggle [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-18 10:33:43
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I stop a web page from scrolling to the top when a link is clicked that triggers javascript? I'm using jquery's slidetoggle to show/hide divs. the element that controls the sliding is a text link ( some text inside <\a>) which has href="#" so it will look like a link (underline, cursor change). the problem is that when the link is clicked, in addition to the sliding effect, the page scrolls to top. i

Python Selenium Get All “href” attributes

丶灬走出姿态 提交于 2019-12-18 09:48:10
问题 How will I get all the "href" attributes for this "h2" titles on this page? <h2 class="entry-title"> <a href="http://www.allitebooks.com/deep-learning-with-python-2/" rel="bookmark">Deep Learning with Python</a> </h2> What I have tried doesn't get the href, is: title = driver.find_elements_by_class_name('entry-title') title[0].get_attribute('href') This did not get the links for "a" tag. And if I do a find all elements on "a" tag, it will return every href on the page (which isn't what I

Include html in email

谁都会走 提交于 2019-12-18 09:46:14
问题 I need to include some HTML things in PHP, for example to add <a href="#">link</a> in a message like this: <?php $to = $themail; $subject = "Expiration d'une annonce"; $body = "Hey,\n\n"; // I need to include a link here in the body like <a href ="http://www.www.com"> Link </a> mail($to, $subject, $body) ?> Any ideas? 回答1: I suggest using PHPMailer, easy to use, takes care of all nesseccery headers, easy attachment sending, multiple recipients etc. http://phpmailer.worxware.com/index.php?pg

Absolute URL's acting like relative URL's

巧了我就是萌 提交于 2019-12-18 08:55:40
问题 When I have a link like http://site.com, clicking it goes to that URL just fine. But when the link is just www.site.com , it adds this URL to the parent website and consequently does not go to the URL. So, clicking on <a href='www.site.com'>site</a> creates this in the browser taskbar: www.parentsite.com/www.site.com . How can I fix this without using preg_replace ? I am fairly new to this game. 回答1: Because www.parentsite.com is interpreted as a relative address , like for example index.htm

How to write in 'mailto' body link to current page

孤街浪徒 提交于 2019-12-18 03:37:54
问题 I have mailto button in all pages of my site and I want to write reference to that page in e-mail body. In one page I can have <a class="email" title="Email a friend" href="mailto:?subject=Interesting%20information&body=I thought you might find this information interesting:%20%0d%0ahttp://www.a.com/Home/SiteMap/tabid/589/Default.aspx">Email</a> But how can I make this generic for all pages? 回答1: This is the pure javascript solution: <a class="email" title="Email a friend" href="#" onclick=

Create download link for music or video

和自甴很熟 提交于 2019-12-17 18:59:59
问题 i have html file with video and audio file. and i want to links file such as mp3 or mp4 using tag a href and download that file. My video and audio file stored in same folder with my html file. i have tried this code : <a href="music/hermin.mp3" target="_blank">download</a> but not downloaded my file, just open a new tab with a play pause controls in the center. from this question i get to add "download" to my href tag, but it is for modern browser. How about for old browser? how i can create

Javascript getElement by href?

試著忘記壹切 提交于 2019-12-17 17:45:08
问题 I've got the script below var els = document.getElementsByTagName("a"); for(var i = 0, l = els.length; i < l; i++) { var el = els[i]; el.innerHTML = el.innerHTML.replace(/link1/gi, 'dead link'); } However this searches through the page and takes about 20 seconds to do it as there are LOTS of links. However I only need to target the a 's that have a specific href , for eg. "http://domain.com/" So ideally I'd like to be able to do this in a similar fashion to jQuery, but without using a

Changing the href of a link tag using javascript

我是研究僧i 提交于 2019-12-17 16:54:12
问题 Hi I am trying to change the href of a link tag so that when a button is pressed a new style sheet is loaded. This is what I have so far- function addcss() { var findlink = document.getElementsByTagName("link"); findlink.href = "stylesheetxhtml.css"; } Any Help Much appreciated Thanks 回答1: You can't set the href directly like that, because document.getElementsByTagName returns all the <link> tags (as a NodeList ). If you're positive you only have one, use this: var findlink = document