<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS Сохранить .html из фрейма]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6202&amp;type=atom" />
	<updated>2011-09-11T14:37:41Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6202</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS Сохранить .html из фрейма]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=51417#p51417" />
			<content type="html"><![CDATA[<p>Нашел интересный код:<br /></p><div class="codebox"><pre><code>Dim InternetExplorer
&#039;/// Создаём экземпляр нового класса
Set InternetExplorer = New InternetExplorerClass
&#039;/// Делаем IE видимым
InternetExplorer.Application.Visible = True

InternetExplorer.Application.Navigate &quot;http://www.myshkin.ru/frameset.htm&quot;

&#039;// Описываем события
Sub InternetExplorer_DocumentComplete(pDisp, URL)

    &#039;/// Т.к в это событие сваливается загрузка каждого HTMLWindow, то ждём пока не загрузиться наше главное окно    
    if InternetExplorer.Application.LocationURL &lt;&gt; URL Then Exit Sub
    
    &#039;/// Получаем ссылку на сам документ
    Set Document = pDisp.Document
    &#039;/// Получаем объект родительского окна
    Set Window = Document.parentWindow

    &#039;/// Подсчитываем колличество фреймов
    Dim FramesCount

    FramesCount = Window.Frames.length

    &#039;/// Если фрейм один или их несколько
    If FramesCount &gt; 0 Then
        MsgBox &quot;В странице найдено &quot; &amp; FramesCount &amp; &quot; фреймов&quot;,vbInformation
        &#039;/// Перебираем фреймы по ID
        For FrameID = 0 to Window.Frames.Length-1
            &#039;/// Получаем фрейм как объект
            Set Frame = Window.Frames(FrameID)
            &#039;/// Возвращаем содержимое его документа в сообщение
            MsgBox Frame.Document.body.outerhtml,vbInformation,&quot;Содержимое фрейма &quot; &amp; FrameID
        Next
    Else
    &#039;/// Если фреймов нет
        MsgBox &quot;В странице не найдено фреймов&quot;,vbExclamation
    End if
End Sub

Sub InternetExplorer_OnQuit()
    MsgBox &quot;Вы закрыли Internet Explorer&quot;,vbInformation,&quot;Internet Explorer&quot;
    Wscript.Quit
End Sub

&#039;/// Класс модуль InternetExplorer
Class InternetExplorerClass
    Public Application

    Private Sub Class_Initialize
        &#039;/// Вся идея в создании объекта через WScript. Вторым параметром указывается префикс функций-обработчиков событий
        Set Application = WScript.CreateObject(&quot;InternetExplorer.Application&quot;, &quot;InternetExplorer_&quot;)
    End Sub

    Sub Class_Terminate
        &#039;/// Для того, чтобы WScript не завершил выполнение сценария при попытке уничтожить модуль,
        &#039;/// делаем цикл, который завершается, если объект IE перестал существовать.
        Do
            WScript.Sleep 10
        Loop Until Application = &quot;&quot;
    End Sub
    
End Class</code></pre></div><p>Вместо вывода сообщения я сохранил все html с каждого фрейма. Но опять же.... Код не работает пока не перегрузится родительский фрейм. Мистика! Все упирается в FrameID Когда выбрасываю все лишнее опять ошибка. Как с этим бороться? Помогите! Ну очень нужно!</p>]]></content>
			<author>
				<name><![CDATA[Mickey666x]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26846</uri>
			</author>
			<updated>2011-09-11T14:37:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=51417#p51417</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS Сохранить .html из фрейма]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=51386#p51386" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>JSman пишет:</cite><blockquote><p>Доступ к содержимому фрейма осуществляется посредством свойства windowContent, которое доступно после события onload фрейма.</p></blockquote></div><p>Меня интересует WSH. Вбил в код процедуру события Window_OnLoad(), а оно не произошло.... Это событие вероятно для HTA. Погуглил, ничего толкового не нашел. Внесу еще одну очень важную точность: Когда в этом фрейме переходишь по какой нибудь ссылке, остальная страница не перегружается. После загрузки этого фрейма мне и нужно сохранить HTML.</p>]]></content>
			<author>
				<name><![CDATA[Mickey666x]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26846</uri>
			</author>
			<updated>2011-09-10T21:14:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=51386#p51386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS Сохранить .html из фрейма]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=51375#p51375" />
			<content type="html"><![CDATA[<p>Доступ к содержимому фрейма осуществляется посредством свойства windowContent, которое доступно после события onload фрейма.</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2011-09-10T15:51:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=51375#p51375</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS Сохранить .html из фрейма]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=51363#p51363" />
			<content type="html"><![CDATA[<p>Доброго времени суток! <br />Необходимо мне сохранить один html документ, который находится в одном из фреймов. Для того чтоб сохранить содержимое именно того фрейма я в URL ищу определенную комбинацию символов. Должно работать, но когда запускаю выскакивает ошибка: Интерфейс не поддерживается. Код: 80004002<br /> </p><div class="codebox"><pre><code>Sub IE_DocumentComplete(pDisp, URL)

    If InStr(URL, &quot;123&quot;) &gt; 0 Then
        Set Document = pDisp.Document
        Set Window = Document.parentWindow
        Set Frame = Window.Frames(FrameID)    &#039;На этой строке ошибка
        Set File = fso.createtextfile(&quot;C:/1.html&quot;)
        File.Write (Frame)
        File.Close
    End If

End Sub</code></pre></div><p>Помогите! В чем может быть ошибка?</p>]]></content>
			<author>
				<name><![CDATA[Mickey666x]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26846</uri>
			</author>
			<updated>2011-09-09T20:33:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=51363#p51363</id>
		</entry>
</feed>
