SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why isn't this working?

    PHP Code:
    <script>
    function 
    lol() {
    myFrame.document.open();
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");
    myFrame.document.close();
    }
    </script>

    <iframe name="myFrame" id="myFrame" height="700" src ="http://www.google.pt" width="100%"></iframe>

    <script>lol();</script> 
    The result should be the google's page with the "LOLOLOLOLLO" added at the end(or begining?).

  2. #2
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai, India
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can try something like this
    Code:
    <iframe name="myFrame" id="myFrame" height="700" src ="" width="100&#37;"></iframe>
    <script>
    vikrantObj = document.getElementById("myFrame");
    vikrantObj.src = "http://www.google.pt/search?site=&hl=pt-PT&q=LOLOLOLOLLO";
    </script>
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.

  3. #3
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vikrantkorde View Post
    you can try something like this
    Code:
    <iframe name="myFrame" id="myFrame" height="700" src ="" width="100%"></iframe>
    <script>
    vikrantObj = document.getElementById("myFrame");
    vikrantObj.src = "http://www.google.pt/search?site=&hl=pt-PT&q=LOLOLOLOLLO";
    </script>
    No, i want to change the InnerHtml of the Iframe, not redirect the page.

  4. #4
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?

  5. #5
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    up up

  6. #6
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script>
    
    function lol() {
    
    var myFrame = document.getElementById('myFrame');
    
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");
    
    myFrame.document.close();
    
    }
    
    </script>
    
    
    
    <iframe name="myFrame" id="myFrame" height="700" src ="http://www.google.pt" width="100&#37;"></iframe>
    
    
    
    <script>lol();</script>
    Try that..

  7. #7
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mark_W View Post
    Code:
    <script>
    
    function lol() {
    
    var myFrame = document.getElementById('myFrame');
    
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");
    
    myFrame.document.close();
    
    }
    
    </script>
    
    
    
    <iframe name="myFrame" id="myFrame" height="700" src ="http://www.google.pt" width="100%"></iframe>
    
    
    
    <script>lol();</script>
    Try that..
    No it didnt work, i tested it this way:

    PHP Code:
    <script>

    function 
    lol() {

    var 
    myFrame document.getElementById('myFrame');
    alert("Hi!!");
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");
    alert("done!");
    myFrame.document.close();

    }

    </script>



    <iframe name="myFrame" id="myFrame" height="700" src ="http://www.google.pt" width="100%"></iframe>



    <script>lol();</script> 
    Notice the lines alert("Hi!!"); and alert("done!");

    When i run it, he says "Hi!!", but then it DOESNT say "done!", meaning that the script crashes somewhere between those 2 alerts, meaning that the problem is the line:
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");


  8. #8
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mr Jojo View Post
    No it didnt work, i tested it this way:

    PHP Code:
    <script>

    function 
    lol() {

    var 
    myFrame document.getElementById('myFrame');
    alert("Hi!!");
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");
    alert("done!");
    myFrame.document.close();

    }

    </script>



    <iframe name="myFrame" id="myFrame" height="700" src ="http://www.google.pt" width="100%"></iframe>



    <script>lol();</script> 
    Notice the lines alert("Hi!!"); and alert("done!");

    When i run it, he says "Hi!!", but then it DOESNT say "done!", meaning that the script crashes somewhere between those 2 alerts, meaning that the problem is the line:
    myFrame.document.write("LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL");

    I tested the script (in IE7, doesnt work in FF) that I posted and it worked fine.

    The google page with LOLOLOLOLOLOLO.... was displayed.

  9. #9
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mark_W View Post
    I tested the script (in IE7, doesnt work in FF) that I posted and it worked fine.

    The google page with LOLOLOLOLOLOLO.... was displayed.
    I tested with FF. Why doesnt it work with FF?


    Thanks!


    Edit: The LOLOLOLOL appears outside the iframe in IE7 :s

  10. #10
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i tried this line now on IE7:

    myFrame.document.body.InnerHTML="LOLOLOLOLOLOLOLOLOLOLOLOLOLOL<br>LOLOLOLOLOL";

    but it doesnt do nothing as wel...

  11. #11
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you might be fighting a loosing battle with this, what is it you are actually trying to do, since there may be a better solution.

  12. #12
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think Iframe.DOCUMENT isn't the right property, the .document doesnt reffer to the iframe's inner page.


    edit: I want to change the HTML of the page that the Iframe opens.

  13. #13
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mr Jojo View Post
    I think Iframe.DOCUMENT isn't the right property, the .document doesnt reffer to the iframe's inner page.


    edit: I want to change the HTML of the page that the Iframe opens.
    It seems that you're trying to change the content on a different domain, which isn't allowed. Read the error console.
    Tab-indentation is a crime against humanity.

  14. #14
    SitePoint Addict Mr Jojo's Avatar
    Join Date
    May 2007
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Logic Ali View Post
    It seems that you're trying to change the content on a different domain, which isn't allowed. Read the error console.
    So its time to develop another plugin to firefox isnt it...?
    Some webpage intersector.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •