Advanced browser management

See also "Using Tcl to write WWW client side applications within the WWW browser", "BrowseX", "Invoking browsers", ...


The following code is relevant to Windows environment. Perhaps someone who is a Windows developer can explain what the code is trying to do?

I'll explain this at some point:

    package require tcom
    wm overrideredirect . on
    pack [canvas .c -background blue -height 20 -width 20]
    wm attributes . -topmost 1 ;# added so you can see the blue square

    proc paste_on_top_IE toplevel {
        set application [::tcom::ref getactiveobject \
                             InternetExplorer.Application]
        wm geometry . +[$application Left]+[$application Top]
        #raise .
        update idletasks
        after 300 [list paste_on_top_IE $toplevel]
    }

    paste_on_top_IE .

Notice the use made of tcom.

LES: I tried, but nothing happens. What am I looking at?

[Eventually explain Browser Helper Objects, XUL, toolbar SDK, ...]


Communication with an existing browser instance, as opposed to invoking browsers:

  • windows: netscape (and other browsers) respond to a few DDE commands.
  • unix:
  • mozilla / netscape: recognizes a -remote flag that attempts to re-use an existing browser process, or you can communicate with netscape on unix without the -remote flag with an extension[L1 ] [L2 ]:
  • konqueror: in KDE you can make use of the "kfmclient" command (type "kfmclient --commands" for reference).
  • opera: has a set of remote commands to open URLs and files, add bookmarks and window management (type "opera --help" for reference).

Yes, it does, eventually. There is a Tcl-extension that does the same thing (communicating with Netscape using X Window Properties) without starting another instance of Netscape, which works much faster (almost instantly and without any overhead). I haven't tried it with recent versions of Tcl/Tk, though.

ftp://ftp.procplace.com/pub/tcl/sorted/net/netscape-remote-v1.2/


Jacob Levy Pat Thoyts and I were hacking around on the Tcl chat. The goal was to write some Tcl code that makes Internet Explorer go to a website while sending an HTTP REFERER header under the control of the directing Tcl program. Pat came up with the following, using tcom:

    package require tcom                               ;# Use tcom
    set url http://www.targetsite.com/                 ;# The site to visit
    set referer http://www.referringsite.com/          ;# The "faked" referring site
    set flags 0                                        ;# Any flags to send
    set targetframe ""                                 ;# Where to display visited site
    set postdata ""                                    ;# Any post-data to send
    set headers "Referer: $referer\n"                  ;# Headers to send (incl
                                                       ;# "faked" referer)

    set ie [tcom::ref createobject "InternetExplorer.Application"]
    $ie Visible 1
    $ie Navigate $url $flags $targetframe $postdata $headers

Of course you can get an existing already-active instance with the "getactiveobject" method demonstrated above, if you don't want to start a new instance. You can try and see what happens, by hitting http://mod3.net/cgi-bin/test3.cgi which is a CGI script that will print out the CGI environment. You'll see that it sends whatever HTTP Referer you said to send.

The InternetExplorer.Application object has many other cool things that you can use, it's fully documented at http://wi.wu-wien.ac.at/rgf/rexx/orx13/tmp/InternetExplorer.Application_1.html

More of the same above, but [L3 ] is the official Microsoft documentation of methods, properties, and events.


Steve Blinkhorn From the current Microsoft documentation:

    In Internet Explorer 6 or later,
    you can navigate through code
    only within the same domain as the application hosting the WebBrowser control.
    Otherwise, this method is disabled.

Does this mean what I think it means, viz. that the above now has very restricted utility?