Archive for January, 2005

Open This URL

January 22, 2005

I finally sat down to find a solution to a problem that been bothering me for a while now. Sometimes I see a URL in a web site (this mostly happens in forums or blogs), which is not a link, so if you want to see it, you must copy and paste it.

Avant Browser version 10 came with a little toolbar that sometimes show near your selection, but this toolbar is not predictable – I couldn’t figure out when exactly Avant decides to show it, and it only has a Search button. Normally, when Google is searched for a URL, this URL is opened, but I don’t want to count on this.

So, what I did is creating a file in d:\winnt\web named OpenThisURL.html, with the following content:

<script>
external.menuArguments.open(external.menuArguments.document.selection.createRange().text);
</script>

And I also added a new registry key to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt named “Open This &URL” with default value set to d:\WINNT\Web\OpenThisURL.html. I also added a binary value named Contexts, with its value set to “10 00 00”. Now, after restarting the browser, selecting the URL text, and right-clicking adds an “Open This URL” menu item, which opens it in another window.

This even works well in Avant Browser.

Advertisements

Formatting code

January 20, 2005

I really need to understand how to format properly in the blog. The blogger editor kind of drivinig me nuts.

First Post – Firefox fights

January 20, 2005

I really don’t know what to write on my first post, but Joel says I should write one (great article, by the way. As usual. I should really get to read the JoS book sometime), so I guess I should just start.

Today I stayed late since I go to the Achla meeting, and Sefi was kind enought to pick me.

Anyway, I just had a big fight with Firefox today. First of all, it insists on blocking my popups, no matter what I tell him. I wonder if this is because I have TBE installed. I guess I need to reinstall a clean Firefox so I can blame all the weird behaviors I found on it. I don’t use it as my day-to-day browser anyhow. (I really love Avant Browser. I do hope that the little features I still miss will be entered soon.) I also tried to install a different theme, but failed. At first the themes page didn’t loaded, and then it claimed the jar file is corrupted. I really don’t know how all of the geeks keep up with this crap. It is event worse than MS problems.

The real problem was getting the update via XMLHttpRequest to work.

Our code looks like this:

function getXMLHTTP()
{
try
{
return new ActiveXObject(“Msxml2.XMLHTTP”)
}
catch(e)
{
try
{
return new ActiveXObject(“Microsoft.XMLHTTP”)
}
catch(oc)
{
}
}

return (typeof XMLHttpRequest == “undefined”) ? null : new XMLHttpRequest();
}

function updateEventList(szJSUpdateCode)
{
if(gXMLHTTP.readyState == 4)
{
if(gXMLHTTP.responseText && gXMLHTTP.responseText.charAt(0) != ”
{
eval(gXMLHTTP.responseText); // call retrieved JS code to get events
} else {
alert(“Failed to download ‘” + gszURL + “‘”);
}
gszURL = null;
}
}

var gXMLHTTP = null;
var gszURL = null;
function sendRequest(szURL)
{
if(gXMLHTTP == null)
gXMLHTTP = getXMLHTTP();

if(gXMLHTTP == null)
return false;

if(gXMLHTTP.readyState != 0)
gXMLHTTP.abort()

gXMLHTTP.onreadystatechange = updateEventList;
gszURL = szURL;
gXMLHTTP.open(“GET”, szURL, true); // true means work asynchronically
gXMLHTTP.send(null);
}

It is called from the main page to update the list, but when an event is being updated in popup, the popup called opener.sendRequest() with the updated URL, to update the list, and then window.close(). This works well in IE, but for some reason, Firefox decided to stop the download and set the readyState to true without any data in the time that popup closed itself. I don’t know exactly why it is, but the solution was to write:

function delayedRequest(szURL)
{
setTimeout(“sendRequest(‘” + szURL.replace(/\’/g, “\\\'”) + “‘);”, 1);
}

And make the popup call delayedRequest.