Linking to a section within a new HTML page - javascript

I am creating a navigation bar for a website and I would like the button to link to the contact section on my homepage (index.html). Currently if you are on the page that has my portfolio and want to go to this section it just goes to the top of my homepage rather than the contact section which is about halfway down the page (has the alt id "#contact."
I currently have this code in my navbar class:
CONTACT
How can I make it go directly to an element with an ID from a link on an external page?

Do this:
CONTACT

Related

website is opening from that section where I left it

I have my portfolio website where I have put links to another section like this
Contact me
and I have also added preloader to my website.
Now there are my social media links in contact me section of my website.So when I click on them it redirects me to my social media profile.
Social media
But the problem is when I come back from the social media account to my portfolio site again, in spite of opening at home section it is directly jumping to contact me section. and the url-bar is showing like this
http://1xx.0.0.1:5500/index.html#contact
So how can I prevent this?
It's kind of a workaround but if it doesn't conflict with other functions of your page you could redirect the user on pageload
window.onload = function() {
window.location.replace("http://1xx.0.0.1:5500/index.html");
}

Manipulating page bookmark position

I'm using Bootstrap to create a single page portfolio, I'm using bookmark links to navigate the page, however I want the page to land earlier than the position it lands on, I am pointing to the div I assigned the Id to it. is there anyway to do it?
Let's say, you want to go to footer on click of Goto Footer link
Goto Footer
Then, the footer block should have
<div id="footer-block">Page Footer</div>

Page Redirect but show section of target page

Is this possible without JS?
I have a menu item which links to a to a section of the home page.
<a class="menu-item-link one-page-nav-item" href="#payments">Payment Options</a>
Of course this works only for the page where the id is present in the DOM. Can I change the link so that it will work from another page without JS on the target page for scrolling. That is the link opens new page and scrolls to the section.
I tried this but it does not work.
<a class="menu-item-link one-page-nav-item" href="http://myurl.com#payments">Payment Options</a>
All examples I am finding refer to linking to a page section on the current page.
Thanks!

Call JavaScript from external link

I am trying to create a horizontal parallax site. Everything is working nicely, when I click the menu the slides move swiftly to the horizontal direction and the corresponding slide is displayed.
I have an external HTML page, that has the same structure as the main site and the problem is that when I click this page's menu, it goes to the site but lands on the first slide.
I want a script so that when I click on this external HTML page link, the page should land on the site, but then it should slide to the corresponding slide.
Main menu link looks like this:
<a onclick="HORIZONTAL.ANIM.instance.move(3);" id="sec4" href="javascript:void(0);">About Us</a>
I want to click on About Us link on external page and then it should land on the main site and then the above script should run and slide should move.
First refer user to new page ( for example http://newpage.com" )with slide id in hash.
About Us
in that new page create a script after page loads that slides to specified slide passed.
window.onload = function() {
var id = window.location.hash.substr(1);//get id from url after hash
HORIZONTAL.ANIM.instance.move(id);
};

How to refresh a home page or go to the home page with one link?

Alright so here's my dilemma, I have a refresh link on my blog that refreshes the current page you're on. I want the link to, if you're on the homepage (/) to refresh and if you're on a different page, say /tagged/me to go to the homepage / the current html I have for the links section is:
<div id="linkz">
refresh
- fask
- face
- more</div>
p.s. my blog is here and the links are in the sidebar.
I'm not exactly sure if this is what your question is asking but if you want to go to the home page, just set the link to
Home Page
On every single page. No need for Javascript, just straight up HTML.
if you simply want the link to refresh to the homepage, why not just href it to the homepage? Just make it href="/".

Categories