Reload two iframes on one iframed page!

Discussion in 'Javascript' started by Freshman, Jan 5, 2010.

  1. Freshman

    Freshman Guest

    I have two php scripts running and iframes the result from both of
    them on one html-page. This page is then iframed into my website...

    I need the option to reload the two original iframes. I have tried to
    add this into the header of the page with the two iframed results:

    <script type="text/javascript">
    <!--
    function Reload () {
    var f = document.getElementById('iFrame',iFrame2');
    f.src = f.src;
    }
    //-->
    </script>

    And this button to call the script:

    <form><input type="button" value="Reload" onclick="Reload();"></form>


    But it doesnt reload anything. My two iframed results are given id
    iFrame and iFrame2.

    Any advice?
     
    Freshman, Jan 5, 2010
    #1
    1. Advertising

  2. Freshman

    David Mark Guest

    On Jan 4, 8:22 pm, Freshman <> wrote:
    > I have two php scripts running and iframes the result from both of
    > them on one html-page. This page is then iframed into my website...
    >
    > I need the option to reload the two original iframes. I have tried to
    > add this into the header of the page with the two iframed results:
    >
    > <script type="text/javascript">
    > <!--
    > function Reload () {


    Don't capitalize functions that are not constructors.

    > var f = document.getElementById('iFrame',iFrame2');


    What is the second argument supposed to do?
     
    David Mark, Jan 5, 2010
    #2
    1. Advertising

  3. Freshman

    Freshman Guest

    On 5 Jan, 04:16, David Mark <> wrote:
    > On Jan 4, 8:22 pm, Freshman <> wrote:
    >
    > > I have two php scripts running and iframes the result from both of
    > > them on one html-page. This page is then iframed into my website...

    >
    > > I need the option to reload the two original iframes. I have tried to
    > > add this into the header of the page with the two iframed results:

    >
    > > <script type="text/javascript">
    > > <!--
    > > function Reload () {

    >
    > Don't capitalize functions that are not constructors.
    >
    > > var f = document.getElementById('iFrame',iFrame2');

    >
    > What is the second argument supposed to do?


    Thanks for reply!

    The "f" refers to the id of the two iframes: iFrame and iFrame2.

    I tried to de-capitalize the function call, but it didn't solve the
    issue. The iframed documents doesn't reload.
     
    Freshman, Jan 5, 2010
    #3
  4. Freshman

    David Mark Guest

    Freshman wrote:
    > On 5 Jan, 04:16, David Mark <> wrote:
    >> On Jan 4, 8:22 pm, Freshman <> wrote:
    >>
    >>> I have two php scripts running and iframes the result from both of
    >>> them on one html-page. This page is then iframed into my website...
    >>> I need the option to reload the two original iframes. I have tried to
    >>> add this into the header of the page with the two iframed results:
    >>> <script type="text/javascript">
    >>> <!--
    >>> function Reload () {

    >> Don't capitalize functions that are not constructors.
    >>
    >>> var f = document.getElementById('iFrame',iFrame2');

    >> What is the second argument supposed to do?

    >
    > Thanks for reply!


    NP.

    >
    > The "f" refers to the id of the two iframes: iFrame and iFrame2.


    But that method takes only one argument:-

    https://developer.mozilla.org/En/DOM/Document.getElementById

    >
    > I tried to de-capitalize the function call, but it didn't solve the
    > issue. The iframed documents doesn't reload.


    Stop guessing. It rarely leads to success.
     
    David Mark, Jan 5, 2010
    #4
  5. Freshman

    Freshman Guest

    On 5 Jan, 09:32, David Mark <> wrote:
    > Freshman wrote:
    > > On 5 Jan, 04:16, David Mark <> wrote:
    > >> On Jan 4, 8:22 pm, Freshman <> wrote:

    >
    > >>> I have two php scripts running and iframes the result from both of
    > >>> them on one html-page. This page is then iframed into my website...
    > >>> I need the option to reload the two original iframes. I have tried to
    > >>> add this into the header of the page with the two iframed results:
    > >>> <script type="text/javascript">
    > >>> <!--
    > >>> function Reload () {
    > >> Don't capitalize functions that are not constructors.

    >
    > >>> var f = document.getElementById('iFrame',iFrame2');
    > >> What is the second argument supposed to do?

    >
    > > Thanks for reply!

    >
    > NP.
    >
    >
    >
    > > The "f" refers to the id of the two iframes: iFrame and iFrame2.

    >
    > But that method takes only one argument:-
    >
    > https://developer.mozilla.org/En/DOM/Document.getElementById
    >
    >
    >
    > > I tried to de-capitalize the function call, but it didn't solve the
    > > issue. The iframed documents doesn't reload.

    >
    > Stop guessing.  It rarely leads to success.– Skjul sitert tekst –
    >
    > – Vis sitert tekst –


    I guess I have to look for another way of reloading the iframed
    documents.
     
    Freshman, Jan 5, 2010
    #5
  6. Freshman wrote:

    > I have two php scripts running and iframes the result from both of
    > them on one html-page. This page is then iframed into my website...


    The resource that your iframe includes is only relevant if its URI has
    another protocol, port or host part. In that case what you want to do
    cannot be done in a default browser environment for security reasons
    (Same Origin Policy, SOP).

    > I need the option to reload the two original iframes. I have tried to
    > add this into the header of the page with the two iframed results:


    The HEAD element is _not_ the header (cf. RFCs 1945 and 2616). There is no
    page, there is an (X)HTML _document_.

    > <script type="text/javascript">


    OK.

    > <!--


    Remove this, it is unnecessary and potentially harmful.

    > function Reload () {


    As David said. But do not simply lowercase this because then you might
    overwrite an existing method. Name it differently, starting lowercase
    (e.g. `iframeReload').

    > var f = document.getElementById('iFrame',iFrame2');


    You have a syntax error here; any error console would have shown it: The
    *ignored* second argument is either not a proper identifier (that is what
    the script engine would complain about) or not properly delimited (if we
    assume that you wanted a string value instead); remove it.

    If you want to reload two iframes at a time, either use a loop over an
    array of string values, or two assignments.

    > f.src = f.src;


    This may or may not reload the iframe. Better use one of these (in order
    of increasing compatibility and, unfortunately, standards-compliance):

    window.frames["iFrame"].location.reload();
    f.contentWindow.location.reload();
    f.contentDocument.defaultView.location.reload();

    For the first one you might need to give the iframe a name (i.e. `name'
    attribute) in order to be backwards-compatible.

    > }


    OK.

    > //-->


    Remove this.

    > </script>
    >
    > And this button to call the script:
    >
    > <form><input type="button" value="Reload" onclick="Reload();"></form>


    You do not want the form because your FORM element is not Valid (the
    required `action' attribute is missing).

    You do not need the form because the INPUT element can stand alone, and you
    do not submit anything here.

    You want to generate that INPUT element dynamically (e.g. with
    `document.write') so that it does not confuse users with browsers without
    scripting capability (where clicking would not have any effect).

    > But it doesnt reload anything. My two iframed results are given id
    > iFrame and iFrame2.


    BAD -- borken as designed, see above. You should also use better,
    preferably lowercase IDs.

    Please read the FAQ before posting here again:
    <http://jibbering.com/faq/#posting>


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Jan 5, 2010
    #6
  7. Freshman

    David Mark Guest

    Freshman wrote:
    > On 5 Jan, 09:32, David Mark <> wrote:
    >> Freshman wrote:
    >>> On 5 Jan, 04:16, David Mark <> wrote:
    >>>> On Jan 4, 8:22 pm, Freshman <> wrote:
    >>>>> I have two php scripts running and iframes the result from both of
    >>>>> them on one html-page. This page is then iframed into my website...
    >>>>> I need the option to reload the two original iframes. I have tried to
    >>>>> add this into the header of the page with the two iframed results:
    >>>>> <script type="text/javascript">
    >>>>> <!--
    >>>>> function Reload () {
    >>>> Don't capitalize functions that are not constructors.
    >>>>> var f = document.getElementById('iFrame',iFrame2');
    >>>> What is the second argument supposed to do?
    >>> Thanks for reply!

    >> NP.
    >>
    >>
    >>
    >>> The "f" refers to the id of the two iframes: iFrame and iFrame2.

    >> But that method takes only one argument:-
    >>
    >> https://developer.mozilla.org/En/DOM/Document.getElementById
    >>
    >>
    >>
    >>> I tried to de-capitalize the function call, but it didn't solve the
    >>> issue. The iframed documents doesn't reload.

    >> Stop guessing. It rarely leads to success.– Skjul sitert tekst –
    >>
    >> – Vis sitert tekst –


    WTF? I didn't write that extra gibberish.

    >
    > I guess I have to look for another way of reloading the iframed
    > documents.


    No, you need to stop guessing and start reading and understanding.
     
    David Mark, Jan 5, 2010
    #7
  8. Thomas 'PointedEars' Lahn wrote:

    > Freshman wrote:
    >> f.src = f.src;

    >
    > This may or may not reload the iframe. Better use one of these (in order
    > of increasing compatibility and, unfortunately, standards-compliance):
    >
    > window.frames["iFrame"].location.reload();
    > f.contentWindow.location.reload();
    > f.contentDocument.defaultView.location.reload();


    Should read "*decreasing* compatibility and *increasing* standards-
    compliance".


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Jan 5, 2010
    #8
  9. Freshman

    Freshman Guest

    On 5 Jan, 14:29, Thomas 'PointedEars' Lahn <> wrote:
    > Thomas 'PointedEars' Lahn wrote:
    > > Freshman wrote:
    > >> f.src = f.src;

    >
    > > This may or may not reload the iframe.  Better use one of these (in order
    > > of increasing compatibility and, unfortunately, standards-compliance):

    >
    > >   window.frames["iFrame"].location.reload();
    > >   f.contentWindow.location.reload();
    > >   f.contentDocument.defaultView.location.reload();

    >
    > Should read "*decreasing* compatibility and *increasing* standards-
    > compliance".
    >
    > PointedEars
    > --
    > Use any version of Microsoft Frontpage to create your site.
    > (This won't prevent people from viewing your source, but no one
    > will want to steal it.)
    >   -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)


    Thank you all, specially Thomas! Now it works like a charm, and yes, I
    have opened PHP 5 Unlashed. time to read and hopefully help others in
    some time. Have a nice day!
     
    Freshman, Jan 5, 2010
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Me
    Replies:
    0
    Views:
    403
  2. Robert Oschler
    Replies:
    0
    Views:
    83
    Robert Oschler
    Sep 6, 2005
  3. zalun
    Replies:
    3
    Views:
    90
    Thomas 'PointedEars' Lahn
    Mar 22, 2006
  4. Replies:
    5
    Views:
    114
    shimmyshack
    Jun 27, 2007
  5. Sharkie
    Replies:
    2
    Views:
    75
    Sharkie
    May 27, 2008
Loading...

Share This Page