HTML open URL from a href data attribute - html

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>

Related

Download image when clicking on the image in react

I have a simple app that fetches images from Unsplash API. I would like users to click on the image, and download it and also maybe for the image to open in a new tab too.
The urls.regular is just a simple url like https://images.unsplash.com/photo-1543332164-6e82f355badc?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjE3OTUzOH0
After reading other issues on stackoverflow, I added "download" at the end of my a tag.
<div>
<a href={urls.regular} title={description} download>
<img
src={urls.regular}
/>
</a>
</div>
I have also tried the following in my a tag:
href={urls.regular}
target="_blank"
rel="noopener noreferrer"
download={urls.regular}
You should define onclick event for the a tag.
<a href={urls.regular} title={description} download onclick="onClick(urls.regular)">
function onClick(url) {
window.open(url, '_blank');
}

Angular go to outside page using link

Using link for open another page outside of project
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" href="https://www.google.kz/">
Web Page
</a>
</div>
but when click to link, opened this page: http://localhost:4200/google.kz - local page, not "google.kz"
How to make, open google.kz outsite link, not trying to find in local page?
You can use target="blank" as follows.
<a class="h3" href="https://www.google.kz/" target="_blank">
target
Where to display the linked URL, as the name for a browsing context (a tab, window, or iframe).
_blank: usually a new tab, but users can configure browsers to open a new window instead.
It should work the way you've described it, but another way of doing it is using the document.location api.
Example:
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" (click)="navigate()">
Web Page
</a>
</div>
inside your component:
navigate(){
document.location = "https://www.google.kz/"
}

How to make HREF link to Nothing while having target _blank without JS inside Modal?

i am using this inside Modal:
<a target="_blank"
id="changeme"
rel="noopener noreferrer"
href="javascript:void(0)"
>
Visit Site here
</a>
but it still opens a new tab. Other answers were without target="_blank" tag.
Is it possible without using JS to make the link does nothing when clicked?

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>