The idea is to send the current URL via AJAX to a PHP. This works when I put it with button onclick in a <script> tag, but when I add “javascript:(function() { // Code })();” around it and make it a bookmark, it fails to work at all. Here’s the code:
javascript:(function(){
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","quickpost?url=" + encodeURI(window.location.href) + "&rand=" + math.random(),true);
xmlhttp.send();
})();
I am bemused and befuddled.
You need to change first letter of the object “Math” it is with big “M”