Redirect to specific page position Next.js - javascript

for some reason when i click on the link
<Link href="/mypage#mydiv" passHref>
I get redirected to the position of the div with id="mydiv". But if i try to access http://localhost:3000/mypage#mydiv this does not work. Any help? I need to produce a link like that to send an email withit it and so that when the receiver clicks on it gets redirected to specific page position. Thanks

Related

Is there a way in nightwatch to click an element but not navigate to the new page?

Is there a way in nightwatch where if I click on a link, it shouldn't redirect me to the url of the link but instead stay on the current page and just update the browser url?
So if I have a link like:
<a href='/hello' />
And I click on the link above it should just change the url to /hello and stay on the current page.
I didn't find this feature in the docs anywhere.

Changing tabs and landing back on the same tab?

Ok, I do not have code for this so I would need assistance here. I have a page that has multiple tabs worth of information. If I proceed to an entirely new page (URL) and then hit back on the browser, is there a way to land back on the tab I left off of?
when you click on a tab you can append a url parameter e.g. ?tab=tab1. And when you load the page you can check you're url parameters and default to that tab if it is in the parameter.
Here's an example that's similar. When you click on the toolbar on the left on bootstrap's getting started page it appends that item to the url. so when i click on 'support' the url looks like http://getbootstrap.com/getting-started/#support and when you go to that url it automatically scrolls you to that section on the page.

How to center the page in popup after open bookmarklet?

javascript:q=location.href;p=document.title;void(open('http://example.page/links/bookmarklet_new?
link%5Burl%5D='+encodeURIComponent(q)+'&link%5Btitle%5D='+encodeURIComponent(p),'Page','toolbar=no,width=700,height=350'));
Im using Bookmarklet script like above. But in case if user is not logged he is redirected to root_path. But then I would like to scroll or center page to login form. I tried override styles. But how to check when page is open in popup window?
Have your bookmarklet add a query string parameter like &view=popup, then the page you open can check the query parameter and change the HTML or CSS as necessary. If your page redirects, make sure it checks for the view parameter and passes it to the next page.
Another option for showing the correct part of the page within the window is to use a hash and a fragment identifier in the url. For example #loginform.

Iframe submits and user is redirected back to original page, but iframe still appears to be present?

I have some JavaScript that spawns an iframe which requires the user to fill out some details. After they submit the iframe form, they are redirected to where they were previously; however, the iframe appears to still be present as right clicking in firefox brings up "This Frame" options. In addition, I am unable to click links or anything on the page.
On the other hand, if I include a function that closes the iframe after the form submits, the user is again redirected back to the original page, but there are no right click "This Frame" options this time and all the links on the page can be clicked.
Can anyone explain to me what is going on here? Thanks!
If using Javascript to redirect, try adding this in front of the redirection:
window.top.location.href = "http://www.site.com";
Else, use target="_top":
<form action".." target="_top">
</form>

Javascript/Jquery : get document referrer, when clicked browser's back button

Situation:
I have page1.html, on which i need to get document referrer
For example, i go to page0.html, then go to page1.html
On page1.html there are list of subpages
I click on some of them and go to page1_sub1.html
Then i click browser's back button and go to page1.html
On page1.html i need to get referrer (page1_sub1.html)
but document.referrer actually shows as page0.html
So, is it possible to get document referrer if clicked back button of browser or user go back via referrence like
« Back
No, that won't work. If needed, you can use cookies to store the history of pages users have opened—but that's complicated, and will fail if the user has your site open in different tabs.

Categories