javascript pass current url as parameter instead of data from textbox
<p>I need to pass the url where the javascript is at the moment instead of using the url in the textbox.
Currently I have textbox and a button, I am getting the url from the textbox and then using it in the javascript. I want only to press the button and the script to get automatically the page where the code is. For example, if I have the code at www.mypage.com, I want when I'll click the button the javascript to get the url automatically and play with it. 
Here is the complete code I am using:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;&lt;/title&gt;


        &lt;script type="text/javascript" src="External/base64.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="External/canvas2image.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="External/jquery-1.6.2.min.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="build/html2canvas.js?221"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="build/jquery.plugin.html2canvas.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="http://www.hertzen.com/js/ganalytics-heatmap.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript"&gt;

            var date = new Date();
            var message,
            timeoutTimer,
            timer;

            var proxyUrl = "http://html2canvas.appspot.com";

            function addRow(table, field, val) {
                var tr = $('&lt;tr /&gt;').appendTo($(table));

                tr.append($('&lt;td /&gt;').css('font-weight', 'bold').text(field)).append($('&lt;td /&gt;').text(val));



            }

            function throwMessage(msg, duration) {

                window.clearTimeout(timeoutTimer);
                timeoutTimer = window.setTimeout(function () {
                    message.fadeOut(function () {
                        message.remove();
                    });
                }, duration || 2000);
                $(message).remove();
                message = $('&lt;div /&gt;').html(msg).css({
                    margin: 0,
                    padding: 10,
                    background: "#000",
                    opacity: 0.7,
                    position: "fixed",
                    top: 10,
                    right: 10,
                    fontFamily: 'Tahoma',
                    color: '#fff',
                    fontSize: 12,
                    borderRadius: 12,
                    width: 'auto',
                    height: 'auto',
                    textAlign: 'center',
                    textDecoration: 'none'
                }).hide().fadeIn().appendTo('body');
            }

            $(function () {

                $('ul li a').click(function (e) {
                    e.preventDefault();
                    $('#url').val(this.href);
                    $('button').click();
                })

                var iframe, d;




                $('input[type="button"]').click(function () {
                    $(iframe.contentWindow).unbind('load');
                    $(iframe).contents().find('body').html2canvas({
                        canvasHeight: d.body.scrollHeight,
                        canvasWidth: d.body.scrollWidth,
                        logging: true

                    });

                });

                $('button').click(function () {

                    $(this).prop('disabled', true);
                    var url = $('#url').val();
                    $('#content').append($('&lt;img /&gt;').attr('src', 'loading.gif').css('margin-top', 40));

                    var urlParts = document.createElement('a');
                    urlParts.href = url;

                    $.ajax({
                        data: {
                            xhr2: false,
                            url: urlParts.href

                        },
                        url: proxyUrl,
                        dataType: "jsonp",
                        success: function (html) {


                            iframe = document.createElement('iframe');
                            $(iframe).css({
                                'visibility': 'hidden'
                            }).width($(window).width()).height($(window).height());
                            $('#content').append(iframe);
                            d = iframe.contentWindow.document;

                            d.open();

                            $(iframe.contentWindow).load(function () {

                                timer = date.getTime();

                                $(iframe).contents().find('body').html2canvas({
                                    canvasHeight: d.body.scrollHeight,
                                    canvasWidth: d.body.scrollWidth,
                                    logging: true,
                                    proxyUrl: proxyUrl,
                                    logger: function (msg) {
                                        $('#logger').val(function (e, i) {
                                            return i + "\n" + msg;
                                        });

                                    },
                                    ready: function (renderer) {
                                        $('button').prop('disabled', false);
                                        $("#content").empty();
                                        var finishTime = new Date();

                                        var table = $('&lt;table /&gt;');
                                        $('#content')
                                        .append('&lt;h2&gt;Screenshot&lt;/h2&gt;')
                                        .append(renderer.canvas)                                     
                                        .append(table);

                                        Canvas2Image.saveAsJPEG(renderer.canvas);



                                    }

                                });

                            });

                            $('base').attr('href', urlParts.protocol + "//" + urlParts.hostname + "/");
                            html = html.replace("&lt;head&gt;", "&lt;head&gt;&lt;base href='" + urlParts.protocol + "//" + urlParts.hostname + "/' /&gt;");
                            if ($("#disablejs").prop('checked')) {
                                html = html.replace(/\&lt;script/gi, "&lt;!--&lt;script");
                                html = html.replace(/\&lt;\/script\&gt;/gi, "&lt;\/script&gt;--&gt;");
                            }
                            // console.log(html);
                            d.write(html);
                            d.close();
                        }
                    });
                });
            });        
        &lt;/script&gt;      
        &lt;base /&gt;
    &lt;/head&gt;
    &lt;body&gt;        
        &lt;div style="float:left;width:500px;"&gt;
            &lt;label for="url"&gt;Website URL:&lt;/label&gt;
            &lt;input type="url" id="url" value="http://www.google.com" /&gt;&lt;button&gt;Get screenshot!&lt;/button&gt;
            &lt;!-- &lt;input type="button" value="Try anyway" /&gt;--&gt;&lt;br /&gt;
           &lt;/div&gt;      
        &lt;div style="clear:both;"&gt;&lt;/div&gt;          
        &lt;div id="content"&gt;&lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Thanks in advance, Laziale</p>
