Angularjs link issue in html5Mode [duplicate] - javascript

This question already has answers here:
Reloading the page gives wrong GET request with AngularJS HTML5 mode
(23 answers)
Closed 7 years ago.
I am using angularjs , and I am using html5Mode.
Before using html5Mode , links work in both same page and new tab. Link like this:
http://localhost:81/vahidnajafi/#/about
But in html5Mode, it works only in same page, but when I open it in new tab it goes to 404 Not found page.
http://localhost:81/vahidnajafi/about
Thanks.

Your need to redirect or reroute the request to your root url on the server.
Your server returns a 404 before angular gets the chance to do something with that route.

Related

Changing subdomain without refreshing the page [duplicate]

This question already has answers here:
how to fully change url without reloading the page to new url?
(2 answers)
Closed 3 years ago.
Is it possible to change change subdomain without refreshing the page?
E.g. from www.somedomain.com to aaa.somedomain.com without full reload?
Edit: I need to switch subdomain part only so in above example somedomain.com stays same, only www is changed to aaa
what you are looking for is History.pushState(), but as described here,
It can't be done. This is by design. There are no exceptions.
From the Mozilla pushState documentation:
The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception.

How twitter changes url without reloading page? [duplicate]

This question already has answers here:
How do I modify the URL without reloading the page?
(20 answers)
Closed 6 years ago.
Recently I've noticed that if we are at our profile view/url (http://twitter.com/profileName) and click on one of our tweets to see its details on popup, the url changes (http://twitter.com/profileName/status/statusId) without reloading the page (no # in url used).
With further investigation, I've noticed that window.history changes, from:
{ title: "profileName (#profileName) | Twitter" }
to:
{ inOverlay: true, rollbackCount: 1 }
I'm currently working on own Single Page App stack, and stuck on writing own router - looking forward for alternatives against currently trending # usage and thought that understanding this twitter hack can help me a bit.
They use the HISTORY API:
window.history.pushState("", "", '/newpage');
Reference: https://blog.twitter.com/2012/implementing-pushstate-for-twittercom

How to fix "Not Found" Facebook connect script? [duplicate]

This question already has answers here:
Facebook sdk.js returns 404 error
(3 answers)
Closed 6 years ago.
I'm using this to login Facebook via Javascript and I'm having this 404 error. Has anyone solved this problem?
Edit: Duplicate for Facebook sdk.js returns 404 error
This was working before, but now it seems the .net isn't working anymore. I tried https://connect.facebook.com/en_US/sdk.js instead of https://connect.facebook.net/en_US/sdk.js and it works now
Someone from the Facebook Team mentioned that a workaround is to change to the URL to: connect.facebook.com instead of connect.facebook.net.
Source:
https://developers.facebook.com/bugs/949091578557056/

How to check if your site is loaded in iframe and fetch parent URL? [duplicate]

This question already has answers here:
Access parent URL from iframe
(19 answers)
Closed 6 years ago.
I am currently developing an app that will be loaded through iframe and I am interested in fetching URL from parent site.
top != self -> true if framed
top.location.href -> get url of top page
window.parent.location.href -> get url of parent

Disable working of browser's back button on logout in jsp [duplicate]

This question already has answers here:
How do we control web page caching, across all browsers?
(29 answers)
Closed 6 years ago.
I am developing a web application using struts2 and jsp. I want to implement logout functionality in it. Although, I am able to remove the session but the browser's back button sends me back to the previously visited pages. I added the following code in each of the jsp file for preventing the caching. But this is not working. Kindly help.. So that after logout one cannot access the pages.
Code :-
<%
response.setHeader("Cache-Control","no-cache"); // HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0);
%>
I have added this code in head tag of each and every jsp page.
You could use JavaScript into your jsp page and use some logic with JSTL to run this script only when it is a logout action.
history.pushState(null, null, '');
window.addEventListener('popstate', function (event) {
history.pushState(null, null, '');
});
It prevents user to back to previous page.

Categories

Resources