| | |
Javascript Bookmarklet - URL Redirect
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2006
Posts: 10
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Dec 2006
Posts: 10
Reputation:
Solved Threads: 0
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:
To get the current URL, you just use the following:
From there, you can concatenate that into your URL as an argument.
Regards,
Drew
I was able to do this on my own by finding a few resources on the web. Here's what I came up with:
javascript Syntax (Toggle Plain Text)
javascript:javascript:var baseURL ='http://www.example.com/';location.href=baseURL+'RESTOFTHEURLREDIRECT'
To get the current URL, you just use the following:
javascript Syntax (Toggle Plain Text)
encodeURIComponent(location.href)
From there, you can concatenate that into your URL as an argument.
Regards,
Drew
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: AJAX Post/Get variable from one page to the next?
- Next Thread: want to remove href="#" from JavaScript Function link
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor date debugger dependent disablefirebug dom dropdown editor element embed engine events explorer ext file form forms getselection google gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe image() images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl maps math media microsoft object onerror onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post programming progressbar rated regex runtime safari scriptlets scroll search security session shopping size software sql star stars text textarea unicode validation variables web webservice website windowsxp wysiwyg \n





