tags:

views:

291

answers:

1

hello, I need to know the url on wich the user currently is.(with firefox)
I thought of a keylogger to keep track of the url,
but what when the user clicks a link?
The title`s not enough, I need the complete url.
With IE this is easy, but with firefox it isnt.
for IE i'm using:

private string GetUrlFromIE()
{
IntPtr windowHandle = GetForegroundWindow();
IntPtr childHandle;
String strUrlToReturn = "";

//IE's toolbar container
childHandle = FindWindowEx(windowHandle,IntPtr.Zero,"WorkerW",IntPtr.Zero);
if(childHandle != IntPtr.Zero)
{
    //get a handle to address bar
    childHandle = FindWindowEx(childHandle,IntPtr.Zero,"ReBarWindow32",IntPtr.Zero);
    if(childHandle != IntPtr.Zero)
    {
        // get a handle to combo boxes
        childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBoxEx32", IntPtr.Zero);
        if(childHandle != IntPtr.Zero)
        {
            // get a handle to combo box
            childHandle = FindWindowEx(childHandle, IntPtr.Zero, "ComboBox", IntPtr.Zero);
            if(childHandle != IntPtr.Zero)
            {
                //get handle to edit
                childHandle = FindWindowEx(childHandle, IntPtr.Zero, "Edit", IntPtr.Zero);
                if (childHandle != IntPtr.Zero)
                {
                    strUrlToReturn = GetText(childHandle);
                }
            }
        }
    }
}
return strUrlToReturn;
}

any ideas?

A: 

In javascript, you can access the URL by way of

window.location.href
James Maroney
how could i run that in firefox without changing the url?
alex
It only changes the url if you set it to something. To get the url, you can: var theUrl = window.location.href;It only redirects the user if you set it to something window.location = "http://www.stackoverflow.com";
James Maroney
yes but how can I run that script in firefox? if i run file:///.../script.js or something like that ill gonna chage the url
alex