Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Reload two iframes on one iframed page!

Reply
Thread Tools

Reload two iframes on one iframed page!

 
 
Freshman
Guest
Posts: n/a
 
      01-05-2010
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?
 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      01-05-2010
On Jan 4, 8:22*pm, Freshman <(E-Mail Removed)> 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?
 
Reply With Quote
 
 
 
 
Freshman
Guest
Posts: n/a
 
      01-05-2010
On 5 Jan, 04:16, David Mark <(E-Mail Removed)> wrote:
> On Jan 4, 8:22*pm, Freshman <(E-Mail Removed)> 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.
 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      01-05-2010
Freshman wrote:
> On 5 Jan, 04:16, David Mark <(E-Mail Removed)> wrote:
>> On Jan 4, 8:22 pm, Freshman <(E-Mail Removed)> 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...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.
 
Reply With Quote
 
Freshman
Guest
Posts: n/a
 
      01-05-2010
On 5 Jan, 09:32, David Mark <(E-Mail Removed)> wrote:
> Freshman wrote:
> > On 5 Jan, 04:16, David Mark <(E-Mail Removed)> wrote:
> >> On Jan 4, 8:22 pm, Freshman <(E-Mail Removed)> 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...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.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-05-2010
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
 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      01-05-2010
Freshman wrote:
> On 5 Jan, 09:32, David Mark <(E-Mail Removed)> wrote:
>> Freshman wrote:
>>> On 5 Jan, 04:16, David Mark <(E-Mail Removed)> wrote:
>>>> On Jan 4, 8:22 pm, Freshman <(E-Mail Removed)> 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...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.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-05-2010
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.)
 
Reply With Quote
 
Freshman
Guest
Posts: n/a
 
      01-05-2010
On 5 Jan, 14:29, Thomas 'PointedEars' Lahn <(E-Mail Removed)> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to submit iframed form to top or whole window Sharkie Javascript 2 05-27-2008 05:06 PM
can u read selected text in an iframed google page?!?!?! jojoba@gmail.com Javascript 5 06-27-2007 08:52 AM
iframed version of the site and back button problem zalun Javascript 3 03-22-2006 02:12 PM
Easy way for user to allow cookies from my IFRAMED web page? Robert Oschler Javascript 0 09-06-2005 09:10 PM
iframe help - change two iframes with one click Me HTML 0 02-09-2004 02:25 AM



Advertisments