Reload two iframes on one iframed page!

F

Freshman

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?
 
D

David Mark

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?
 
F

Freshman

Don't capitalize functions that are not constructors.


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.
 
T

Thomas 'PointedEars' Lahn

Freshman said:
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
 
D

David Mark

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.
 
T

Thomas 'PointedEars' Lahn

Thomas said:
Freshman said:
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
 
F

Freshman

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,743
Latest member
WoodrowMea

Latest Threads

Top