简体   繁体   中英

HTML href does not link to expected location because of JavaScript

I want to link to a html file on my harddrive. For now I have my index.html which schould link to site2.html in the same folder.

<a href="site2.html">Site 2</a>

The site should link to the second site, which is in the same folder. But it does link nowhere. In my browser the href tag is shown as such:

<a href="/site2/">Site 2</a>

How can I link to the expected location?

EDIT:

I made a website on Jimdo and now I want it to locally work. Now the problem is that every change I make is not made on the website itself. It looks like there is a JavaScript script preventing changes. It looks like the script links to the actual Jimdo Website, but without redirecting. This is some code from the JavaScript:

window.__WEBSITE_PROPS__ = { * , navigationTree": [{"name:" "site2", *, "slug:" "site2", * }] * } 
<a href="site2.html">Site 2</a> 

or

<a href="/site2.html">Site 2</a>

or

<a href="./site2.html">Site 2</a>

Kindly update your link like this. also you can read how to add link on anchor here

Because I made the website with Jimdo there is some JavaScript that loads or builds the whole website always from the Jimdo server. I still have no permanent solution but if you have the same problem, just remove the JavaScript and everything should work nicely.

Snippets from the JavaSccript code:

window.__WEBSITE_PROPS__ =
        {
            "basePath": "/", "websiteId": "330de313-d32b-4309-9a22-6c591781b107",   
            ...
            "pagePathMap":
            {
                "807f7760-9b36-499d-96e7-22cefd4996eb": "index.html",
                "1dec3d7b-46c1-47c1-97b0-c4f86ffcde13": ".themen.html",
                "59bb866a-3663-4d6e-b7a9-72ff25640f9e": "/ablauf.html",
                "52723e9e-9a6b-467c-ab89-14d61559eb57": "\partner.html",
                "92ff761a-9ab2-4a89-bfe9-01c5ee1ef8ea": "faq.html",
                "6eb0383b-f9fc-440f-94ae-2e3fea38002a": "impressum.html",
                "a4bb260b-da6e-45be-8fce-07d05c57bb7f": "datenschutz.html",
                "b85600c7-51c5-4680-98ec-3f70f471b8a3": "cookie_richtlinie.html",
                "2a8bf66b-8fca-44b4-b0e9-7cca3fb5d6f8": "cookie_einstellungen.html"
            },
        };

As you can see the pagePathMap prevents the linking from happening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM