Lets say we have a website build on AngularJS. We figure out how to hide not pretty /#!/ characters from url by setting HTML5mode on true. But we have a problem when visitor came to the website with old url link including /#!/ i.e. www.example.com/#!/products/ it redirect him to homepage www.example.com which of course we didn't meant we expected to redirect him to www.example.com/products/ so we tried write many rewrite rules which says, that if you go to website through old link with /#!/ than it should redirect you to the new link without /#!/. But this doesn't work for us and we are sure rewrites rules has been OK.
Can be there some problem with AngularJS setting?
Thanks for your time and advices!
Fragment identifiers are never sent to the server, so you can't deal with them using server side code (including rewriting). You have to process them with client side code.
I solved this problem, but I´m not 100% sure how does it work and I would like to know it. All I need to do was add hashPrefix('!') behind setting of html5Mode.
$locationProvider.html5Mode(true).hashPrefix('!');
Now it works as we wanted, but what hashPrefix('!') actually do? I just found from documentation that it "Configure existing providers" but why hiding of #! works without this?
Please can you explain me my last two questions about this topic. Thank you
Related
Recently I got a project where I had to make some changes in a Wordpress website with some customized theme (Besocial + BBpress) and custom coding. Now, I have almost done all changes but there is a strange bug/error where login and register functionality sometimes work as intended and sometimes it doesn't. Also, after login, user has to be redirected to a News Feed (much like Facebook) but that too sometimes work and sometimes doesn't. I am not being able to find what is the error or bug. Can you please suggest something to make my process easier? The project is already delayed for 2 weeks.
Thanks, any help appreciated :)
a)open website in private window, see if issue is still their, if not than delete browser cookies.
b)Deactivate plugins and check the issue.
c)Check by changing the theme.
d)Reset Permalinks
e)check your .htaccess
By doing these thing you will know from where issue is coming.
I am pretty sure I know the answer, but throwing this out in hopes that someone has an idea I have not thought of.
I am doing a Cordova app for a client that wants one of the pages to have their current mobile site wrapped (below navigation bar). The app is using Angular JS and I was just going to wrap that page with an iFrame... but ran into the X-Frame-Options: Deny issue that they wrapped their entire site under.
Ideally they will remove that, but with politics it might not be possible.
Is there any way else that I can load this site up without an iframe? I am guessing not because of the security issues this was trying to solve in the first place.
The best way that I was able to solve it in the end was to use a plug-in that launched a new webview with the site inside it, then modifying the webview and plugin to look like the rest of the app.
Here is the great plugin I started with:
https://github.com/apache/cordova-plugin-inappbrowser
My first question here :)
I want a way to load a page inside iframe while changing/replacing a part of the urls of any links present in the webpage with alternate text.
eg.
Suppose we load a website in iframe like "mywebsite.com" which has a link to another site inside the loaded page
eg. http s://www.facebook.com/abcd?id=text
http s://www.facebook.com/efgh?id=text
.
Then I want the website inside iframe to be loaded with custom urls like:
eg. http s://www.facebook.com/abcd?id=alternatetext
http s://www.facebook.com/efgh?id=alternatetext
Basically I need a way to replace "text" to "alternatetext" .. ON THE FLY while rendering the webpage inside iframe.
How do I do it?
Help me people..
Thanks.
This is completely possible. But I think you may be far off on this. Since you do not include any JavaScript I assume that you have not made any head way on that. This is going to be deep and take some fine tuning, its not just some code snippet that someone can give you. It can totally be done with a scripting language. I recommend you take the time to learn a server side language. I personally use VB.NET at work. You will be amazed with the possibilities.
On another note, if Facebook found out you were displaying their pages online and modifying their links they would surely take some action.
I recommend this question be closed.
This is a follow-up to my previous question.
Suppose there is a single web page with a login form and sign-up link. When a user clicks on the link a new sign-up form is displayed. Suppose also I create separate HTML, CSS, and JavaScript files for both forms for modularity.
Now the web page should contain some JavaScript code to load the login form, when the page is loaded, and load the sign-up form upon click on the link.
Does this approach make sense? Are there any frameworks/libraries, which implement this approach? How would you suggest implement it?
I think the idea has some issues. First you should know that there are some old fashion ways to load another completely separated page in the main document. Using "iframe" tag is one of the most popular and unsecure ways to do such a thing. Showing popups and use "window.open" is another way that can show a new window and load the specific url completely separated. BUT...
There are many reasons that I'm now gonna suggest you not to do that in any of mentioned ways. You can simply use some libraries like "JQuery" to load another html in the current page without any need to load new resources that cause performance issues for you. I believe you should search for "JQuery $.get" and you will see how easy it would be.
Hope it helps.
Cheers
Yes that makes sense to me. I really like this approach as I think breaking an app into smaller chunks will make the development & maintenance much easier.
Basicly you need to load the css and js files by appending a link and script tag respecticly into the head section of the html. For loading the html part of the module you can simply use jQuery.get() method as suggested by other answer.
I have tried to implement it. I recently released my work on this. a small code base. actually in my approach each module has its own folder with its js, html and css files and optionally a server-side file too like a php or aspx file that will be called by javascript to query the server.
here is the project page in github called Yuva
take a look and let me know if this makes sense to you.
What I want to do is be able to see how it will look any website with my javascript attached . I want to create something like selectorgadget working on any website.
The first idea is to use a proxy (eg privoxy) and define a regular expression changing in html: </head> to <script src="http://myserver.com/my_javascript.js"></script></head>. It works, but in such case, I need to set proxy in my browser. And it is not cool because It visible only for me.
Another idea is to write a website that will download page under the hood and show it. How it will work:
Go to page eg.: http://myserver.com/
My index.php will download eg.: www.google.com using http client or curl, replace page source (add my <script> before </head>) and return page to user. It works, but when page contains relative images I'm not able to see it. Rewriting image src, and other script src is not so simple.
Because I want to add only javascript, I thought that you can use iframes. But there is a restriction to the same domain.
Any ideas on how to do it? Maybe some tool? Something with cross-domain iframe?
You can configure Apache web server to work in reverse proxy mode and use your first approach. Hence it will work very similar to your second case, but all replacement Apache server will do for you.
I'll throw Greasemonkey into the list of suggestions. Also note that FireBug allows you to run arbitrary JavaScript on a page, plus a lot more useful stuff for developing & debugging web apps.
(Although from your short description, I agree with awoodland that bookmarklets are probably the best solution.)
Bookmarklets let you do exactly this without any kludges.
if you are using Chrome, you can develop a simple extension and use the content scripts.
You can use the following project which is a node based proxy that can allow you to include any arbitrary JS or CSS in all pages
https://github.com/amitamb/plugin-proxy
I am the developer of the project.