使用JavaScript触发URL

I need a script that triggers a URL(go to the URL and that's it).

What's the shortest way to write this script?

Use window.location.

window.location = 'http://stackoverflow.com';

Or shorter (not recommend though).

location = 'http://stackoverflow.com';

No ajaxical magic needed.

window.location='http://www.google.com';

Of course you could code-golf out the url and the semicolon.

This is a sample AJAX code sample that can be used to fire a silent query to the browser and fetch the response and act on it.

var xmlhttp;

if (window.XMLHttpRequest)
    xmlhttp = new XMLHttpRequest();
else
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            // Do something with the result, like post a notification
        $('#notice').html('<p class="success">'+xmlhttp.responseText+'</p>');
    }
}

xmlhttp.open('GET',url, true);
xmlhttp.send();

Thanks: Use window.location.

window.location = 'http://stackoverflow.com';