🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #50078

Re: Pobieranie zawartości elementu z iframe

#50078
From: Peter May
Date: Mon, 17 May 2010 21:27
69 lines
3120 bytes
W dniu 2010-05-17 20:59, Czesiu pisze:
> On 17 Maj, 20:20, Peter May<peter....@onet.pl>  wrote:
>> W dniu 2010-05-17 19:38, Czesiu pisze:
>>
>>
>>
>>
>>
>>> Witam!
>>> Mam taki kod:
>>> <html>
>>> <head>
>>> <meta http-equiv="content-type" content="text/html;
>>> charset=iso-8859-2">
>>> </head>
>>> <body>
>>> <iframe src="http://www.bezpiecznastrefa.gim3.edu.pl/" id="frame">
>>> </iframe>
>>> <script type="text/javascript">
>>> ramka = document.getElementById("frame");
>>> ramka.style.height = "1000";
>>> document.write(ramka.getElementById("content").innerHTML);
>>> </script>
>>> </body>
>>> </html>
>>> Wiem ,że nie będzie on działać ,ale chciałbym wykonać właśnie coś
>>> takiego ,aby pobrać innerHTML dowolnego elemntu ze strony w iframe i
>>> wyświetlić to na stronie. Jak to zrobić jakieś pomysły bo ja już nie
>>> mam?
>>
>> Nie dawno był o tym wątek. Znajdź "odczytywanie zawartości iframa".
>>
>> --
>> Peter
>
> Ok załatwiłem to!
> Twój przykład działa ,ale z pobraniem zawartości elementu mam problem
> w konsoli błędów w operze dostaje komunikat:
>
> Uncaught exception: TypeError: Cannot convert
> 'doc.document.getElementById("content")' to object
> Error thrown at line 5, column 0 in program code:
>      content.innerHTML =
> doc.document.getElementById("content").innerHTML;
> A kod mam taki:
> <html>
> <head>
> <meta http-equiv="content-type" content="text/html;
> charset=iso-8859-2">
> </head>
> <body>
> <iframe src="http://www.bezpiecznastrefa.gim3.edu.pl/" id="iframeid"
> height="600">
> </iframe>
> <div id="div"></div>
> <script type="text/javascript">
> var myframe = document.getElementById("iframeid");
> var doc = (myframe.contentWindow || myframe.contentDocument);
> div = document.getElementById("div");
> div.innerHTML = doc.document.getElementById("content").innerHTML;
> </script>
> </body>
> </html>

Prawdopodobnie próbujesz dostać się do zawartości <iframe>-a, która 
jeszcze nie załadowała się.

-- 
Peter
Technical Details
Message-ID: <hsscbs$jof$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!lublin.pl!news.onet.pl!not-for-mail
References: <862736a8-a1ca-4744-b81a-f30a09ea298c@j27g2000vbp.googlegroups.com> <hss1dt$grp$1@news.onet.pl> <a04b7da8-4cab-41af-925f-f28a9754c413@q23g2000vba.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!lublin.pl!news.onet.pl!not-for-mail
From: Peter May <peter.may@onet.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: Pobieranie zawartości elementu z iframe
Date: Mon, 17 May 2010 23:27:22 +0200
Organization: http://onet.pl
Lines: 69
Message-ID: <hsscbs$jof$1@news.onet.pl>
References: <862736a8-a1ca-4744-b81a-f30a09ea298c@j27g2000vbp.googlegroups.com>  <hss1dt$grp$1@news.onet.pl> <a04b7da8-4cab-41af-925f-f28a9754c413@q23g2000vba.googlegroups.com>
NNTP-Posting-Host: 188.146.232.228.nat.umts.dynamic.eranet.pl
Mime-Version: 1.0
X-Trace: news.onet.pl 1274131646 20239 188.146.232.228 (17 May 2010 21:27:26 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Mon, 17 May 2010 21:27:26 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; pl; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4
In-Reply-To: <a04b7da8-4cab-41af-925f-f28a9754c413@q23g2000vba.googlegroups.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit