Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS][PHP]Kod źródłowy strony w iframe
kamild
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 16.02.2011

Ostrzeżenie: (0%)
-----


Witam,
Szukam rozwiązania pewnego problemu mianowicie próbuję wyświetlić kod źródłowy strony znajdującej się w IFRAME, udało mi się jedynie odczytać zawartość o zadeklarowanym id. Czy ktoś mógł by pomóc? Pozdrawiam serdecznie

PLIK.html
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Untitled</title>
  6. </head>
  7.  
  8. <style>
  9. iframe {height:200px; width:300px; border:1px solid #000}
  10. </style>
  11.  
  12. <script>
  13. function iframeContent() {
  14. frame = document.getElementById("myFrame")
  15.  
  16. if (frame.contentDocument) {
  17. alert(frame.contentDocument.getElementById("test").innerHTML)
  18. }
  19. else if (frame.contentWindow) {
  20. alert(frame.contentWindow.document.getElementById("test").innerHTML)
  21. }
  22. }
  23. </script>
  24.  
  25. <body>
  26.  
  27. <iframe src="document.html" id="myFrame">
  28. </iframe><br>
  29.  
  30. <button onclick="iframeContent()">OK</button>
  31.  
  32. </body>
  33. </html>
  34.  



IFRAME
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2.  
  3. <html>
  4. <head>
  5. <title>Untitled</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <p id="test">Text</p>
  11.  
  12. </body>
  13. </html>
  14.  
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 19:33