External links bugging

hi, when I deploy my site (https://enesinpoland.netlify.app), everything is perfect. There are some external links in my html, for example;
href=“https://poznan.travel/en/
onclick=“window.open(‘https:poznan.travel/en/’)”
When clicked, another web site should be opened. But instead it says: " # Page Not Found

Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site. "
Please help me. What is wrong with my site?

[

@Deniz Your HTML for that element isn’t quite correct, you’ve got a mix of link and image attributes.

Change:

<img src="./gallery/logo,poznan.jpg" class="poznan-logo" alt="logo of poznan" href="https://poznan.travel/en/" onclick="window.open('https:poznan.travel/en/')" target="_blank">

To:

<a href="https://poznan.travel/en/" target="_blank"><img src="./gallery/logo,poznan.jpg" class="poznan-logo" alt="logo of poznan"></a>

This wraps the image in a standard link.

Thank you so much for your answer. But it unfortunately it has not helped.:man_shrugging:The same code works in my visual studio code’s live server perfect.
here is my github repo; https://github.com/7deniz/enes
please help me…

Nathan Martin via Netlify Support Forums <notifications@netlify.discoursemail.com>, 8 Mar 2023 Çar, 11:09 tarihinde şunu yazdı:

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile: Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

@Deniz You didn’t implement it as I outlined, but still with some onclick JavaScript:

image

The onclick should be entirely unnecessary for a link, since the default behaviour is to open the href, and it acts as “code smell”.

The ultimate source of all your problems with links is your code in /script.js.

You have the following…

const allLinks = document.querySelectorAll("a:link");
allLinks.forEach(function (link) {
  link.addEventListener("click", function (e) {
    e.preventDefault();

I can see the intention is to “smooth scroll” to different points within the page, but the use of e.preventDefault() on ALL links, is preventing the links from navigating to their href.

You need to adjust that functionality so that it only acts upon “on page links”.
E.g. Move the e.preventDefault() into a check like if ( !href.includes( 'http' ) ) { so that it doesn’t act upon your external links.

1 Like

thank you, thank you*million times. :blush::+1::pray: I am 46 years old newbee(swh) trying to learn front-end. This site is a gift for my son studying in Poland. Your last advice worked perfectly.I am grateful for it. Thanks again… You are a great man…

Nathan Martin via Netlify Support Forums <notifications@netlify.discoursemail.com>, 9 Mar 2023 Per, 00:51 tarihinde şunu yazdı:

hi @Deniz Im so glad you found your solution in our community. Good luck on the learning process! (: