admin管理员组文章数量:1332404
I currently have the following JavaScript function that will take current URL and concatenate it to another site URL to route it to the appropriate feedback group:
function sendFeedback() {
url = window.location.href;
newwin = window.open('/?s=' + url, 'Feedback');
}
Not sure if this is the proper terminology, but I want to mask the URL in the window.open
statement to use the URL from the current window.
How would I be able to mask the window.open
URL with the original in JavaScript?
I currently have the following JavaScript function that will take current URL and concatenate it to another site URL to route it to the appropriate feedback group:
function sendFeedback() {
url = window.location.href;
newwin = window.open('http://www.anothersite./home/feedback/?s=' + url, 'Feedback');
}
Not sure if this is the proper terminology, but I want to mask the URL in the window.open
statement to use the URL from the current window.
How would I be able to mask the window.open
URL with the original in JavaScript?
- @Assaf - Instead of displaying "anothersite./home/feedback/?s=www.mysite." in the new browser address bar, I want to display "www.mysite.". – Michael Kniskern Commented Oct 18, 2010 at 23:08
- 1 From what I understand, you cannot manipulate the address bar of the browser window. – Šime Vidas Commented Oct 18, 2010 at 23:23
2 Answers
Reset to default 4Things you could do:
1- Mask the external site in a html frame inside a document from your site.
(for example www.mysite./shortUrl/
)
2-Send a Location
HTTP header (real url will eventually be displayed)
Keep in mind that browsers do their best to show the real address due to phishing concerns.
I wouldn't use javascript if I wanted to mask url even thought it would work with javascript. You wouldn't get much benefits in that scenario.
The reason is simple:
javascript/jQuery = functions belongs to client-side (browswer/your PC/DOM)
links, url, http, and headers = functions belongs to Apache.
Apache is always top level above client-side. Whenever link is fired to SampeLink.html, Apache wakes up and reads the file, but links/urls are already owned before javascript could claim them. So, it is kinda of pointless if you tried to manipulate links in your javascript scripts, even though it works but weak.
I'd point you to this awesome approach: .htaccess and you will be surprised how powerful it is. If .htaccess is presented in the parent folder of SampleLink.html, Apache denies the DOM engine (your browser) from reading files until Apache have finished reading .htaccess.
With your scenario, .htaccess can do some work for you by rewriting links and send "decoy" links to the DOM engine, meanwhile keeping the orginial links/urls behind the curtain; and visitors would reach to 404page if they tried to break the app or whatever you are concerned about.
This is a bit plicated, but it never ceased to fail me. I use this as my "bible" http://corz/serv/tricks/htaccess2.php.
本文标签: url rewritingURL masking in JavaScriptStack Overflow
版权声明:本文标题:url rewriting - URL masking in JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742277226a2445423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论