Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - innerHTML method not working

Reply
 
Old 08-21-2006   #1 (permalink)
=?Utf-8?B?QW5vbnltb3Vz?=


 
 

innerHTML method not working

Hi,

When trying the following piece of code:

$oIE=New-object -COM InternetExplorer.Application
$oIE.navigate2("about:blank")
$oIE.Visible=$True
$html="<html><head></head><body>Hello World!</body></html>"
$oIE.document.body.innerHTML=$html

I am getting the following error:
Property 'innerHTML:' cannot be found on this object; make sure it exists
and is settable.

Any idea what is going wrong? I am using Microsoft IE 6.0.2900 and Windows
PowerShell RC1

Thanks.


My System SpecsSystem Spec
Old 08-21-2006   #2 (permalink)
=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=


 
 

RE: innerHTML method not working

This should do what you want. If last line fails, try the one that is
commented out instead. Hope that helps.

$oIE = New-Object -COM InternetExplorer.Application
$oIE.navigate("about:blank")
while ($oIE.busy) { sleep 1 }
$oIE.visible = $true
$html="<html><head></head><body>Hello World!</body></html>"
$oIE.document.IHTMLDocument2_write("$html")
#$oIE.document.write("$html")

--
greetings
dreeschkind

"Anonymous" wrote:

> Hi,
>
> When trying the following piece of code:
>
> $oIE=New-object -COM InternetExplorer.Application
> $oIE.navigate2("about:blank")
> $oIE.Visible=$True
> $html="<html><head></head><body>Hello World!</body></html>"
> $oIE.document.body.innerHTML=$html
>
> I am getting the following error:
> Property 'innerHTML:' cannot be found on this object; make sure it exists
> and is settable.
>
> Any idea what is going wrong? I am using Microsoft IE 6.0.2900 and Windows
> PowerShell RC1
>
> Thanks.
>

My System SpecsSystem Spec
Old 08-22-2006   #3 (permalink)
=?Utf-8?B?QW5vbnltb3Vz?=


 
 

RE: innerHTML method not working

Thanks ! What if I want to read (and save) the entire contents of the html
page? How would I do that?

"dreeschkind" wrote:

> This should do what you want. If last line fails, try the one that is
> commented out instead. Hope that helps.
>
> $oIE = New-Object -COM InternetExplorer.Application
> $oIE.navigate("about:blank")
> while ($oIE.busy) { sleep 1 }
> $oIE.visible = $true
> $html="<html><head></head><body>Hello World!</body></html>"
> $oIE.document.IHTMLDocument2_write("$html")
> #$oIE.document.write("$html")
>
> --
> greetings
> dreeschkind
>
> "Anonymous" wrote:
>
> > Hi,
> >
> > When trying the following piece of code:
> >
> > $oIE=New-object -COM InternetExplorer.Application
> > $oIE.navigate2("about:blank")
> > $oIE.Visible=$True
> > $html="<html><head></head><body>Hello World!</body></html>"
> > $oIE.document.body.innerHTML=$html
> >
> > I am getting the following error:
> > Property 'innerHTML:' cannot be found on this object; make sure it exists
> > and is settable.
> >
> > Any idea what is going wrong? I am using Microsoft IE 6.0.2900 and Windows
> > PowerShell RC1
> >
> > Thanks.
> >

My System SpecsSystem Spec
Old 08-23-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: innerHTML method not working

What version of IE and of PowerShell are you using?

I'm having some issues of my own with IE 7 beta. On a Win2003SP1 system
running IE 6 and PS RC1, however, I can run your code with no problems.

By the way, if you echo the innerHtml successfully you may think it was
mangled; it's not. The html/head/body tags are not part of the body's
innerHTML. Here's what I get on the Win2003SP1+PSRC1 system:

$ie=New-Object -ComObject InternetExplorer.Application
$ie.navigate2("http://www.google.com")
$ie.Visible = $true
PS> $html="<html><body><bold>Hello World!</bold></body></html>"
PS> $ie.document.body.innerHTML = $html
PS> $ie.document.body.innerHTML
<BOLD>Hello World!</BOLD>


"Anonymous" <Anonymous@discussions.microsoft.com> wrote in message
news:9F20EA0F-CFA6-4A2D-84E2-AFFC1B90779D@microsoft.com...
> Hi,
>
> When trying the following piece of code:
>
> $oIE=New-object -COM InternetExplorer.Application
> $oIE.navigate2("about:blank")
> $oIE.Visible=$True
> $html="<html><head></head><body>Hello World!</body></html>"
> $oIE.document.body.innerHTML=$html
>
> I am getting the following error:
> Property 'innerHTML:' cannot be found on this object; make sure it exists
> and is settable.
>
> Any idea what is going wrong? I am using Microsoft IE 6.0.2900 and Windows
> PowerShell RC1
>
> Thanks.
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Resync method .NET General
InnerHTML not working VB Script
method not many Vista mail
Method invocation failed because [System.String] doesn't contain a method PowerShell
Wmi put() method - what am i doing wrong ? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46