If my url is http://link-ads.blogspot.com/?url=http://stackoverflow.com/
The code below extracts http://stackoverflow.com/
<script type='text/javascript'>
$(document).ready(main);
function main()
{
    $('#download, #imggg').attr('href', getIframeUrl() );
    registerEvents();
    resizeIframe();
}
function getIframeUrl()
{
    var url = window.location.href;
    var iframe_url = 'http://link-ads.blogspot.com/';
    var param_start = url.indexOf("url=");
    if( param_start != -1 ) 
        iframe_url = url.substr(param_start+4,url.length-param_start-4);
    if( iframe_url.indexOf("http://") == -1) 
        iframe_url = "http://" + iframe_url;
    return iframe_url;
}
  </script>
my problem is if the url is http://link-ads.blogspot.com/?url=http://stackoverflow.com/&adclient=12345678kkk1112 the code will extract the url as http://stackoverflow.com/&adclient=12345678kkk1112 when I want the url before &adclient= meaning I only want it to extract http://stackoverflow.com/
 
    