Article View: pl.comp.lang.javascript
Article #50076Re: Pobieranie zawartości elementu z iframe
From: 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>
Technical Details
Message-ID:
<a04b7da8-4cab-41af-925f-f28a9754c413@q23g2000vba.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.stw-bonn.de!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!q23g2000vba.googlegroups.com!not-for-mailReferences:
<862736a8-a1ca-4744-b81a-f30a09ea298c@j27g2000vbp.googlegroups.com> <hss1dt$grp$1@news.onet.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.stw-bonn.de!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!q23g2000vba.googlegroups.com!not-for-mail From: Czesiu <tonyhouk@o2.pl> Newsgroups: pl.comp.lang.javascript Subject: Re: Pobieranie zawartości elementu z iframe Date: Mon, 17 May 2010 11:59:17 -0700 (PDT) Organization: http://groups.google.com Lines: 66 Message-ID: <a04b7da8-4cab-41af-925f-f28a9754c413@q23g2000vba.googlegroups.com> References: <862736a8-a1ca-4744-b81a-f30a09ea298c@j27g2000vbp.googlegroups.com> <hss1dt$grp$1@news.onet.pl> NNTP-Posting-Host: 83.21.188.89 Mime-Version: 1.0 X-Trace: posting.google.com 1274122758 19307 127.0.0.1 (17 May 2010 18:59:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 17 May 2010 18:59:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q23g2000vba.googlegroups.com; posting-host=83.21.188.89; posting-account=IyKkLgoAAAC26yZr7z3wLXEsdrmFk2qZ User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (Windows NT 6.1; U; pl) Presto/2.5.24 Version/10.53,gzip(gfe) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit