Click on Anchor <a> Searches for a page in duplicate nested hierarchy which does not exist - html

I have a list of menus as below, every menu link is an anchor. I am experiencing a very strange behaviour from anchor tag i.e., when I click on any menu it opens the requested page correctly. But on second click system duplicates the directory hierarchy and looks for the requested page where hierarchy does not exist. For example there is a page on path "Pages/Contact/test.aspx", 1st click opens the page. When user clicks 2nd time browser tries to open a page at path "Pages/Contact/Pages/Contact/test.aspx" resulting in exception "The resource cannot be found" error is thrown.
<div id="menu">
<ul class="menu">
<li><span>About Us</span>
<div>
<ul>
<li><a href="Pages/Contact/Phone.aspx" ><span>Phone</span></a></li>
<li><a href="Pages/Contact/Email.aspx" ><span>Email</span></a></li>
</ul>
</div>
</li>
</ul>
</div>

The problem is because you are using relative paths to your pages.
It works the first time because (I assume) you are in the root directory. So clicking the link takes you to 'Pages/Contact/Phone.aspx'. When in phone.aspx, if you click the link again, it looks for this page: Pages/Contact/Pages/Contact/Phone.aspx.
You need to add a / to the beginning of your URL to make it relative to the root of the site:
<ul>
<li><a href="/Pages/Contact/Phone.aspx" ><span>Phone</span></a></li>
<li><a href="/Pages/Contact/Email.aspx" ><span>Email</span></a></li>
</ul>
Or alternatively, because you're using ASP.Net, you can use the ResolveUrl() function to ensure all your links are relative to the root of the solution:
<ul>
<li><span>Phone</span></li>
<li><span>Email</span></li>
</ul>

I believe href="" is your problem here.
Try href="#" or href="javascript:;"

Related

Anchor tag doesn't work in second level pages

I've a menu that contains this content:
<div class="menu">
<ol>
<li data-target="home" >hello</li>
<li data-target="contact" >Contact</li>
<li data-target="policy_privacy" >Privacy</li>
</ol>
</div>
when I'm in the home page the anchors working well (#home, #contact), but if I'm on privacy_policy page, and try to go to home page, nothing happen. How can I detect in some way if I'm not in home page (which contains the anchors) and redirect the user to the home?
If adding separate markup for the privacy_policy page in which you can add the link of the homepage in the anchor tag seems not easy then you should
try something like this.
if (window.location.href.includes("privacy_policy")) {
document.querySelector('#home').href = "https://somesite.com";
}

Getting an error when linking contact form in html i have tried everything

<nav class="Navbar">
<ul>
<li>
<a href=“index.html”>Home</a></li>
<li>
<a href=“contact.html”>About</a></li>
<li>
<a href=“Services.html”>Services</a></li>
<li>
<a href=“Contact.html”>Contact</a></li>
This is the error i get
Cannot GET /%E2%80%9CContact.html%E2%80%9D
The contact form you saved as "contact.html", check that the page can load independently and please check if it is saved in same folder as your document. You might want to get its src/ folder.
close your </ul> and </nav>
check your link and learn about relative and absolute links. a url will solve that problem if it is remote. if its local, make sure its not in a different directory.
check this page out
https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
i bet one of those 2 things helps. keep us posted

Return to the homepage and move to the section

the links on the homepage navbar is an easy scroll when click on it it moves the page the the section with id, but i need the user when they are on any other page not the homepage and click on any links on the navbar, it return back to the homepage and move to the section.
This code doesn't work for me.
How we Work
Try to remove the / before your URL
How we Work
This / is going to the root of your folder. I guess your using relative path, so this should fix the issue.
In your webpage you have this code within "tracking.html":
<h2>About Us</h2>
<ul class="discover triangle hover row">
<li class="col-xs-12">About EvisaXpress</li>
<li class="col-xs-12">Our Team</li>
<li class="col-xs-12">How We Work</li>
</ul>
This is linking to the current page, i.e. "tracking.html". Write instead
How We Work
and you should be fine.
The difference is that in your page this is called:
http://evisax.com/tracking.html#how-we-work
whereas this is what you want to call:
http://evisax.com/index.html#how-we-work
Removing scrolling.js from the Tracking.html file and everything works fine.

Linking multiple html pages

I have used bootstrap nav nav-pills nav-justified
and i have 7 of these
<li>Form</li>
I have been able to click on form which will re-direct to the form page, but I can't seem to return to my home page without clicking back on the browser. I want to be able to just click on the Home button which i've included as part of my 7 <li>s I mentioned earlier. Also i would like to be able jump onto each page from the navbar tab.
<div class="header">
<div class="container">
<ul class="nav nav-pills nav-justified">
<li><a href "#">Home</a></li>
<li><a href "#">About</a></li>
<li><a href "#">JavaScript</a></li>
<li><a href "#">JQuery</a></li>
<li>AngularJS</li>
<li><a href "#">API</a></li>
<li>Form</li>
<li><a href "#">Contact</a></li>
</ul>
</div>
</div>
So from that above, when i click on form, im on the form page, but i cannot go back to the homepage(index.html) unless i click back on the browser, i wanna be able to link to all the lists by clicking each other.
Consider using Ajax to load different pages dynamically (with association with jQuery it said to be simpler to use) for the desired behavior or put everything on the single page and show content only when user clicks the link by JS and CSS.
As soon as you use Bootstrap elements you probably have jQuery already included in your project.
Useful links:
jQuery Ajax
Hiding elements with CSS
Check this page jQuery.get there is a very demonstrative example
$.get("demo_test.asp", function(data, status)
{
alert("Data: " + data + "\nStatus: " + status);
});
where data - data received from the server. It should be your html code to replace the content.
To insert data use:
$.('#Content').html(data); //id="Content" is from the comment
if you do this in a local host and you created these files as i find out when you click on the home you get 404 page the only thing that you have to do is to link your homepage file to the home button if i'm wrong comment me and explain your problem more and then i will help you.

Use <a> in iframe (1) to load page into iframe (2)

I am setting up an iframe styled page. I have iframes for each piece of my page (header, menu, sidebar, content, etc).
My menu iframe had links in it;
<ul id="workMenuItems" style="display:none">
<li><a target="contentframe" href="work/courier.php" id="hrefcourier">Courier</a></li>
<li><a target="contentframe" href="work/scout.php" id="hrefscout">Scout</a></li>
<li><a target="contentframe" href="work/hunt.php" id="hrefhunt">Bounty Hunt</a></li>
<li><a onclick="back()" href="javascript:void(0)" id="back">Back</a></li>
</ul>
When I click on any of these (courier for example) it opens a new tab instead of loading that .php into the contentframe. I checked spelling and everything matches.
Also - I am using Chrome - not sure if that's a known issue off hand.
Thanks!
As a shot in the dark, I added the name element to my iframe and it worked. ID="" apparently isn't enough on this one. Thanks to anyone who looked!