snipt

Ctrl+h for KB shortcuts

JavaScript

JavaScript for Bookmarklet to pass URL to form field

1
2
3
4
5
6
7
(function (formurl, site, name, options) {
    window.open(
        formurl+encodeURIComponent(site),
        name,
        options
    );
}('http://example.com?url=', window.location, 'yourform', 'width=300,height=200'));
https://snipt.net/embed/b5c601ac948d1f1b51020b0c643adff0/
/raw/b5c601ac948d1f1b51020b0c643adff0/
b5c601ac948d1f1b51020b0c643adff0
js
JavaScript
7
2019-06-20T03:37:52
True
False
False
Jan 13, 2013 at 09:20 AM
/api/public/snipt/53424/
javascript-for-bookmarklet-to-pass-url-to-form-field
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">formurl</span><span class="p">,</span> <span class="nx">site</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nb">window</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">formurl</span><span class="o">+</span><span class="nb">encodeURIComponent</span><span class="p">(</span><span class="nx">site</span><span class="p">),</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">name</span><span class="p">,</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">options</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">);</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}(</span><span class="s1">&#39;http://example.com?url=&#39;</span><span class="p">,</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">,</span> <span class="s1">&#39;yourform&#39;</span><span class="p">,</span> <span class="s1">&#39;width=300,height=200&#39;</span><span class="p">));</span> </span></pre></div> </td></tr></table>
"url variable", bookmarklet, javascript, url