slobodif
slobodif

Reputation: 41

Link in html page on android doesn't work

I made two html pages on a desktop computer and transferred them to a mobile phone and put them in the same folder. The operating system on the mobile phone is android 8.1.0. When I open one of the pages, it opens in google chrome but the link to the other page doesn't work.

This is code for first page:

<!doctype HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>index1</title>
    </head>
    
    <body>

        <a href="index2.html">go to index2</a>
            
    </body>
            
</html>

This is code for second page:

<!doctype HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>index2</title>
    </head>
    
    <body>

        <a href="index1.html">go to index1</a>
            
    </body>
            
</html>

Works perfectly on a desktop computer but does not work on a mobile phone.

Upvotes: 3

Views: 2287

Answers (3)

Mo Fayyad
Mo Fayyad

Reputation: 73

I found a solution to this problem by just replace the URL in the browser with the form : file:///storage/emulated/0/folder1/folder2.../file.extention

Upvotes: 1

slobodif
slobodif

Reputation: 41

Problem solved. In my phone, if you want links to work, than links to files do not end with the file name and extension but with the file number. I could read the file number when I opened that file with the google chrome app in the address/search bar. And I had to install some text editor and work directly on mobile. This is what the code for linking two html pages looked like in the end:

First page:

<!doctype HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>index1</title>
    </head>
    
    <body>

        <a href="content://0@media/external/file/7912">go to index2</a>
            
    </body>
            
</html>

Second page:

<!doctype HTML>
<html>
    <head>
        <meta charset="utf-8">
        <title>index2</title>
    </head>
    
    <body>

        <a href="content://0@media/external/file/7911">go to index1</a>
            
    </body>
            
</html>

Thanks a lot guys for the help, I appreciate every effort.

Upvotes: 1

Shady Mohamed Sherif
Shady Mohamed Sherif

Reputation: 15759

Try to put / before your the file name

 <a href="/index1.html">go to index1</a>

Upvotes: 0

Related Questions