Change href location - html

I want to change the link of the href when I click the first paragraph. I tried setting a target but that doesn't seem to work.
<a href="https://youtu.be/DM1sdIntawg" target="youtube">
<p>Click to change the link to the video</p></a>
<a id="youtube" name="youtube" href="https://youtu.be/XphhA4djzko">
<p>This is the changed link to the video</p></a>

I don't believe this is possible without client-side javascript (although I'm not sure about the capabilities of HTML5)
Try this inline code...
<a href="https://youtu.be/DM1sdIntawg" onclick="document.getElementById('youtube').href = this.href;return false;">
<p>Click to change the link to the video</p></a>
<a id="youtube" name="youtube" href="https://youtu.be/XphhA4djzko">
<p>This is the changed link to the video</p></a>
Or the same thing using a function...
function changeLink(ctrl) {
document.getElementById("youtube").href = ctrl.href;
}
<a href="https://youtu.be/DM1sdIntawg" onclick="changeLink(this);return false;">
<p>Click to change the link to the video</p></a>
<a id="youtube" name="youtube" href="https://youtu.be/XphhA4djzko">
<p>This is the changed link to the video</p></a>

Related

HTML open URL from a href data attribute

I'm learning HTML.
I've following code piece:
<a href="#B" id="specialClass" class="primary-btn icon-cart" data-one="#A" data-five="google.com" data-ten="#C" target="_blank">
<span id="pressButton">New Button</span>
</a>
When I press button based on slider and data-five gets triggered, I for some reason open in a new tab mywebsite.com/google.com instead of google.com.
What am I doing wrong?
If it is an address outside your web page you have to put the full path with https://google.es
<a target="_blank" href="https://google.es">Google</a>

download attribute different behaviour for 2 links

below are two links with download attribute.
clicking on both gives different result, why?
<a href="https://www.w3schools.com/images/myw3schoolsimage.jpg" download>
dnld
</a>
<br>
<a href="https://scontent.xx.fbcdn.net/v/t45.1600-4/28204217_6081249221877_6688541583534456832_n.png?oh=9262305ce4d55f669767f01c1be364b1&oe=5B06C1A9" download >Download</a>
w3schools link downloads the image where as the other one simply opens the image.
because the extension should be displayed at end of url
<a href="https://www.w3schools.com/images/myw3schoolsimage.jpg" download>
dnld
</a>
<br>
<a href="https://scontent.xx.fbcdn.net/v/t45.1600-4/28204217_6081249221877_6688541583534456832_n.png" download >Download</a>

Give new email window focus

I have a link on a webpage to open a new message in the default email service. The link opens and works except for the fact that the new window never has the focus. Is there a way to give it focus? I have included the link below.
<a href='mailto:soandso#email.com?Subject=hi' target='_top' id='emailEvents'>soandso#email.com</a>
New Page :
<a href='mailto:test#email.com?Subject=Test' target='_blank' id='emailEvents'>test#email.com </a>
This Page :
<a href='mailto:test#email.com?Subject=Test' target='_self' id='emailEvents'>test#email.com </a>
Use target="_blank"
<a href='mailto:soandso#email.com?Subject=hi' target='_blank' id='emailEvents'>soandso#email.com </a>

Button click doesn't open new window

I have a font awesome icon <i> item inside a a href with a target='_blank' — yet only the text is clickable; clicking on the icon opens a new tab with about:blank, not the actual link.
<a href="..." class="not-light" target="_blank" style="display: block; ">
<i class="fa fa-android"></i> »
</a>
How do I make the icon clickable as well?
For example, click the lightbulb in the footer of the http://ambieye.com/ site's footer.
The <li> is a list. The list must be on the outer and the text in the inner like this :
<li style="display: block; ">
<a href="..." class="not-light" target="_blank">
<i class="fa fa-android"></i> » The text
</a>
</li>
Try it.
The issue was in the javascript handler, not the css/html; the way to find these issues is in Chrome's handlers section, under 'click handler' -
function handleSystemLink(a) {
var url = a.target.href;
The argument a was the i element which did not have href, thus openning a bad link.

How to get URL Line?

On click my icon and go to my Line profile.
http://www.test12345679/lineicon.jpg
Give the url in href attribute like
href="http://google.com"
I think what you want is to have an image or icon that links to your profile.
<a href="URL Line profile">
<img alt="icon" src="http://www.test12345679/lineicon.jpg">
</a>