How do I get input using Javascript in a bookmarklet?
-
I am trying to write some code to append a URL with some text. So that the action would be - click a button, get input from user, go to output. I have tried writing this (I have removed the real URL): "javascript:spam_check=location.href(C… TEXT INPUT HERE)" - this may not display correctly here, so will also explain below. So you can see, I want to insert a username at the end of this URL using javascript - xxxxxx.co.uk/something/?user=, when a user click the bookmarklet, they can enter a username, it will then go to the desired page. I'm a bit of a noob, this should be easy, I've tried some different solutions but can't get it right. Cheers!!
-
Answer:
If it this what you are trying to do, bookmarklet is not the way to go. Button on website. Click button show input field. Collect detail. Submit form. Put details in url and redirect. Bookmarklet are link smart widgets stored in bookmarks, ran by clicking it so it "does something" before site loads or on the current site using javascript code. Regardless, here is an answer to how to activate a bookmarklet. 1) Create a working javascript code, as one block, no function included. 2) If the last action you need is open a url, don't place the url at the begining but at the end of the code use window.location='http://www.gothere.com?… 3) Use a tool to compress javascript (online example in source) 4) Use a tool to encode the comressed script 5) append javascript: to the result string, and that is the url value you use. e.g for alert('woohoo'); you get "alert(%27woohoo%27)%3b%0d%0a" so <a href="javascript:alert(%27woohoo%27)%3b%…
DiggNati... at Yahoo! Answers Visit the source
Related Q & A:
- How do I get on to chat with a real Yahoo tech?Best solution by Yahoo! Answers
- How can I get an overseas job as a civil engineer?Best solution by jobs.monster.com
- How can I get tickets for the serie a Torino-Juventus derby?Best solution by Yahoo! Answers
- How can I get my regular avatar of a real picture back as my avatar instead of the one now?Best solution by Yahoo! Answers
- How do I get into safe mode without a keyboard?Best solution by pistonheads.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.