Thread View: pl.comp.lang.javascript
6 messages
6 total messages
Started by Czesiu
Mon, 17 May 2010 17:38
Pobieranie zawartości elementu z iframe
Author: Czesiu
Date: Mon, 17 May 2010 17:38
Date: Mon, 17 May 2010 17:38
21 lines
1656 bytes
1656 bytes
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?
Re: Pobieranie zawartości elementu z iframe
Author: Peter May
Date: Mon, 17 May 2010 18:20
Date: Mon, 17 May 2010 18:20
27 lines
1780 bytes
1780 bytes
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
Re: Pobieranie zawartości elementu z iframe
Author: Czesiu
Date: Mon, 17 May 2010 18:59
Date: Mon, 17 May 2010 18:59
62 lines
3145 bytes
3145 bytes
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>
Re: Pobieranie zawartości elementu z iframe
Author: Peter May
Date: Mon, 17 May 2010 21:27
Date: Mon, 17 May 2010 21:27
69 lines
3120 bytes
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
Re: Pobieranie zawartości elementu z iframe
Author: Peter May
Date: Mon, 17 May 2010 21:30
Date: Mon, 17 May 2010 21:30
70 lines
3161 bytes
3161 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>
Zainteresuj się tym zdarzeniem onload dla <iframe>-a:
http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/
--
Peter
Re: Pobieranie zawartości elementu z iframe
Author: Czesiu
Date: Tue, 18 May 2010 18:56
Date: Tue, 18 May 2010 18:56
74 lines
3555 bytes
3555 bytes
On 17 Maj, 23:30, Peter May <peter....@onet.pl> wrote:
> 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>
>
> Zainteresuj się tym zdarzeniem onload dla <iframe>-a:
>
> http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentd...
>
> --
> Peter
Wielkie dzięki wszytsko działa!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads