Javascript Bookmarklet - URL Redirect

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Dec 2006
Posts: 10
Reputation: drewrockshard is an unknown quantity at this point 
Solved Threads: 0
drewrockshard drewrockshard is offline Offline
Newbie Poster

Javascript Bookmarklet - URL Redirect

 
0
  #1
Dec 30th, 2008
I was wondering how I could create a bookmarklet that would take someone's current location (href) and redirect to another page with the href as an "argument" to part of a new url. For example:

1. Someone goes to a webpage, decides to click on the bookmarklet.

2. The bookmarklet grabs the URL and then redirects to http://www.example.com/index.php?boo...ROMBOOKMARKLET

Is this possible? It sounds pretty easy, however, my strong point is definitely NOT JavaScript and I have no reason to learn it, except for this little project.

Let me know if you can help.

Regards,
Drew
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 10
Reputation: drewrockshard is an unknown quantity at this point 
Solved Threads: 0
drewrockshard drewrockshard is offline Offline
Newbie Poster

Re: Javascript Bookmarklet - URL Redirect

 
0
  #2
Dec 31st, 2008
Nevermind,

I was able to do this on my own by finding a few resources on the web. Here's what I came up with:

  1. javascript:javascript:var baseURL ='http://www.example.com/';location.href=baseURL+'RESTOFTHEURLREDIRECT'

To get the current URL, you just use the following:

  1. encodeURIComponent(location.href)

From there, you can concatenate that into your URL as an argument.

Regards,
Drew
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC