For example, I have a Bookmarklet, don't know, something like this one:
As far as I understand, the bookmarklet code (with the "&cURL=" thing) takes the URL that is in the adress bar of the browser and then do something with it in order to get a result. Something similar can be done with a selection, by changing some parameters in the bookmarklet (Like with the "Search selection in Google Maps" one) and some others.
How can I "decompile" a bookmarklet in order to make it take the desired data (in this case an URL) from a form?
For example, let's say I want to use the above bookmarklet in a webpage to provide a form that let's the user input a URL and then click a button to get the result.
I've seen other bookmarklets that get the URL from a "?input=" and others from a "?url="
How can I pass bookmarklet's functions to a form?
In a bookmarklet it's actually easiest to use
prompt('Please enter a URL', 'default value') instead of the variable. Displaying a form in the current webpage is rather cumbersome.
If you just need one user-entered value,
prompt() is an easy to use alternative to ask a user for more info. (Of course you can use multiple
prompt() calls, too, but this will probably lead to a confused user)
Try something like this:
<form method="get" action="http://www.pdfdownload.org/web2pdf/Default.aspx">
<input type="hidden" name="left" value="0">
<input type="hidden" name="right" value="0">
<input type="hidden" name="top" value="0">
<input type="hidden" name="bottom" value="0">
<input type="hidden" name="page" value="0">
<input type="text" name="cURL">
And you create an iframe on js.js
var site = location.href;
document.body.innerHTML += "<div style='background-color:white;z-index:1000;position:fixed;right:0;top:0' width='300' height='250'><iframe src='http://www.example.com/bookmarklet.php?q=" + site + "' /></div>";