Solved

javascript URL rewirte

Posted on 2008-09-29
7
1,128 Views
Last Modified: 2013-11-11
I know Ive read this some where.... any one know how to do a URL rewrite in javascript... It was the url in the browser... If I remember right the article was saying that you could do this for when you were using ajax... anyone have an idea on this... thank you for the help...
jeremyBass
0
Comment
Question by:jeremyBass26
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:jose_juan
ID: 22603333
Hi,

pure URL rewrite  using javascript not is possible; a URL rewrite consist in transform a not existing URL into a resource on server, client side transparent.

Obviously, you can check the URL on your error 404 html page (if you can not run scripts on server) and process the document.location.href for redirect client on javascript runtime.

do you understand?

an example of your 404 html page would be

<html>

<head>

<script>

switch( location.href ) {

case 'http://.../a-page': location.href = '/a.htm'; break;

case 'http://.../b-page': location.href = '/b.htm'; break;

case 'http://.../c-page': location.href = '/c.htm'; break;

}

</script>

</head>

<body>

Page not found!

</body>

</html>

Open in new window

0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 22605781
I think I was not clear, or it just the thought... but what I was wanting to do is stop some HTTP requests at the cleint side.... basicaly I have a file being called 12-20 times... but it's the same file.. so the thought was there has to be a way to "capture" the HTTP requests ... I thought I've seen URL rewrites with javascript... but may-be I could have it so that it's more like this... if HTPP request is in array die else execute and push URL to array?  any ideas on that? thanks for the help
jeremyBass
0
 
LVL 5

Expert Comment

by:jose_juan
ID: 22605908
Ops!

In a general case, you can not stop a request petition, probably you like control all links elements on your page and, when user click then check a posible rewrite. is it?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Author Comment

by:jeremyBass26
ID: 22606121
No this is for when an element is called... in this case a link to a swf file.... it's one file that is being called many times ... also it's all in the jQuery script so that thought was that I could do something like "capture" the HTTP requests ... so if HTPP request is in array die else execute and push URL to array? I think... thanks for the help
jeremyBass
0
 
LVL 5

Accepted Solution

by:
jose_juan earned 500 total points
ID: 22607014
0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 22607062
that was the articel I have been looking for... thank you...
0
 
LVL 4

Author Closing Comment

by:jeremyBass26
ID: 31501443
thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now