user2232273
user2232273

Reputation: 4964

a href doesn't work in my project

I have a simple problem with my <a href=""> code: they don't open anymore...

It only worked one time, and then no more.

I don't know why... It would be great if someone can help me with this.

my code:

<div data-role="page" id="p1">
    <div data-role="header" data-theme="a" data-position="fixed" data-id="footer">  
    <a href="Destaque/Destaque.html" data-icon="home" data-iconpos="notext">Home</a>
</div

I tried a lot of things, but I didn't find out what the problem is.

Upvotes: 0

Views: 145

Answers (2)

user2232273
user2232273

Reputation: 4964

Ok. i have find the answer for this problem.

the path i have written was right and the problem was not the relative/absolute path.

the only thing i have to add to this link is rel="external", because the html page that i want to open is in the sub-folder from my projecto.

the following code show the right code for this situation.

<a href="Destaque/Destaque.html" rel="external" data-icon="home" data-iconpos="notext">Home</a>

Upvotes: 1

Jason Sperske
Jason Sperske

Reputation: 30416

It looks like you are experiencing a combination of broken paths and jQuery Mobile's overriding of link behavior.

On the first load you are in the folder containing the sub-folder Destaque, after you click on it your reference directory is Destaque so clicking on it again would try and resolve Destaque/Destaque/Destaque.html. This behavior might not look like a a classic 404 because of jQuery Mobile (it uses ajax to load pages).

To fix this use an absolute path by adding a leading / changing this:

<a href="Destaque/Destaque.html" data-icon="home" data-iconpos="notext">Home</a>

to this:

<a href="/Destaque/Destaque.html" data-icon="home" data-iconpos="notext">Home</a>

This assumes that this sub-folder is in fact in the root of your web app. If not then you need to adjust your absolute path.

Upvotes: 1

Related Questions