欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

VBS InternetExplorer.Application的属性和方法介绍

程序员文章站 2022-06-23 21:04:43
示例代码 set ie = createobject("internetexplorer.application") ie.navigate "//www.j...

示例代码

set ie = createobject("internetexplorer.application") 
ie.navigate "//www.jb51.net" 
wscript.sleep 1000 
ie.toolbar = 0 
ie.visible=false 
ie.document.f1.word.value = kw 
if ie.document.f1.word.value="" then wscript.quit 

上面是在网上看到的,navigate toolbar visible 等都是怎么用的??
怎么网上找不到它们的用法?
下面是一些属性说明:

set ie=wscript.createobject("internetexplorer.application")
ie.menubar=0 '不显示ie对象菜单栏
ie.addressbar=0 '不显示ie对象地址栏
ie.toolbar=0 '不显示ie对象工具栏
ie.statusbar=0 '不显示ie对象状态栏
ie.fullscreen=1 '全屏化ie对象
ie.width=800 '设置ie对象宽度
ie.height=600 '设置ie对象高度
ie.resizable=0 '设置ie对象大小是否可以被改动
ie.visible=1 '设置是否可见
ie.navigate "//www.jb51.net" '设置ie对象默认指向的页面

目的留个备份,方便我以后去msdn上找用法。

internetexplorer object

42 out of 82 rated this helpful rate this topic

controls an instance of windows internet explorer through automation.

members table

the following table lists the members exposed by the internetexplorer object.

events

event description
beforenavigate fires before navigation occurs in the given object (on either a window or frameset element).
beforenavigate2 fires before navigation occurs in the given object (on either a window element or a frameset element).
commandstatechange fires when the enabled state of a command changes.
documentcomplete fires when a document is completely loaded and initialized.
downloadbegin fires when a navigation operation begins.
downloadcomplete fires when a navigation operation finishes, is halted, or fails.
filedownload fires to indicate that a file download is about to occur. if a file download dialog box can be displayed, this event fires prior to the appearance of the dialog box.
navigatecomplete fires after a navigation to a link is completed on either a  element or a frameset element.
navigatecomplete2 fires after a navigation to a link is completed on a window element or a frameset element.
navigateerror fires when an error occurs during navigation.
newprocess creates a new process to handle the navigation.
newwindow fires when a new window is to be created.
newwindow2 fires when a new window is to be created.
newwindow3 raised when a new window is to be created. extends newwindow2 with additional information about the new window.
onfullscreen fires when the fullscreen property is changed.
onmenubar fires when the menubar property is changed.
onquit fires before the internet explorer application quits.
onstatusbar fires when the statusbar property is changed.
ontheatermode fires when the theatermode property is changed.
ontoolbar fires when the toolbar property is changed.
onvisible fires when the visible property of the object is changed.
printtemplateinstantiation fires when a print template is instantiated.
printtemplateteardown fires when a print template is destroyed.
privacyimpactedstatechange fired when an event occurs that impacts privacy, or when a user navigates away from a url that has impacted privacy.
progresschange fires when the progress of a download operation is updated on the object.
propertychange fires when the putproperty method of the object changes the value of a property.
redirectxdomainblocked fired when a cross-domain redirect request is blocked.
setphishingfilterstatus fires to indicate the progress and status of microsoft phishing filter analysis of the current webpage.
setsecurelockicon fires when there is a change in encryption level.
statustextchange fires when the status bar text of the object has changed.
thirdpartyurlblocked fired when a third-party url is blocked.
titlechange fires when the title of a document in the object becomes available or changes.
updatepagestatus not implemented.
windowactivate not implemented.
windowmove not implemented.
windowresize not implemented.
windowstatechanged fires when the visibility state of a content window, such as the browser window or a tab, changes.

methods

method description
clienttowindow computes the full size of the browser window when given the specified width and height of the content area.
execwb executes a command and returns the status of the command execution using the iolecommandtarget interface.
getproperty gets the value associated with a user-defined property name.
goback navigates backward one item in the history list.
goforward navigates forward one item in the history list.
gohome navigates to the current home or start page.
gosearch navigates to the current search page.
navigate navigates to a resource identified by a url or to a file identified by a full path.
navigate2 navigates the browser to a location that might not be expressed as a url, such as a pointer to an item identifier list (pidl) for an entity in the windows shell namespace.
putproperty associates a user-defined name/value pair with the object.
querystatuswb queries the object for the status of commands using the iolecommandtarget interface.
quit closes the object.
refresh reloads the file that is currently displayed in the object.
refresh2 reloads the file that is currently displayed with the specified refresh level.
showbrowserbar shows or hides a specified browser bar.
stop cancels a pending navigation or download, and stops dynamic page elements, such as background sounds and animations.

properties

property description
addressbar sets or gets a value that indicates whether the address bar of the object is visible or hidden.
application gets the automation object for the application that is hosting the webbrowser control.
busy gets a value that indicates whether the object is engaged in a navigation or downloading operation.
container gets an object reference to a container.
document gets the automation object of the active document, if any.
fullname retrieves the fully qualified path of the internet explorer executable.
fullscreen sets or gets a value that indicates whether internet explorer is in full-screen mode or normal window mode.
height sets or gets the height of the object.
hwnd gets the handle of the internet explorer main window.
left sets or gets the coordinate of the left edge of the object.
locationname retrieves the path or title of the resource that is currently displayed.
locationurl gets the url of the resource that is currently displayed.
menubar sets or gets a value that indicates whether the internet explorer menu bar is visible.
name retrieves the frame name or application name of the object.
offline sets or gets a value that indicates whether the object is operating in offline mode.
parent gets the parent of the object.
path retrieves the system folder of the internet explorer executable.
readystate gets the ready state of the object.
registerasbrowser sets or gets a value that indicates whether the object is registered as a top-level browser window.
registerasdroptarget sets or gets a value that indicates whether the object is registered as a drop target for navigation.
resizable sets or gets a value that indicates whether the object can be resized.
silent sets or gets a value that indicates whether the object can display dialog boxes.
statusbar sets or gets a value that indicates whether the status bar for the object is visible.
statustext sets or gets the text in the status bar for the object.
theatermode sets or gets whether the object is in theater mode.
toolbar sets or gets whether toolbars for the object are visible.
top sets or gets the coordinate of the top edge of the object.
toplevelcontainer gets a value that indicates whether the object is a top-level container.
type gets the user type name of the contained document object.
visible sets or gets a value that indicates whether the object is visible or hidden.
width sets or gets the width of the object.

remarks

internet explorer 8. on windows vista, to create an instance of internet explorer running at a medium integrity level, pass clsid_internetexplorermedium (defined in exdisp.idl) to cocreateinstance. the resulting internetexplorermedium object supports the same events, methods, and properties as the internetexplorer object.

examples

the following example uses createobject in microsoft visual basic to launch an instance of internet explorer.

dim ie as shdocvw.internetexplorer
set ie = createobject("internetexplorer.application")

the following c# example launches an instance of internet explorer and navigates to a web page. the code also demonstrates how to create an event handler to listen for the beforenavigate2 event. the project requires a reference to the microsoft internet controls (shdocvw) type library.

using system;
using system.collections.generic;
using system.text;

namespace consoleapplication1
{
  class eventhandlers
  {
    public void onbeforenavigate2(object sender, ref object url, 
                   ref object flags, ref object target, 
                   ref object postdata, ref object headers, 
                   ref bool cancel) 
    {
      console.writeline("beforenavigate2 fired!");
    }
  }

  class program
  {
    static void main(string[] args)
    {
      eventhandlers e = new eventhandlers();
      shdocvw.internetexplorer ie = new shdocvw.internetexplorer();
      object empty = 0;
      object url = "http://www.live.com";

      // override beforenavigate2 event
      ie.beforenavigate2 += new
         shdocvw.dwebbrowserevents2_beforenavigate2eventhandler(
             e.onbeforenavigate2);

      ie.visible = true;
      ie.navigate2(ref url, ref empty, ref empty, ref empty, ref empty);

      system.threading.thread.sleep(5000);

      ie.quit();
    }
  }
} 

object information

clsid clsid_internetexplorer
minimum availability internet explorer 4.0
minimum operating systems windows 98, windows ce 4.0