iframe change params.

J

Jo Claes

Hi,

A friend asked me if i could help him building a lilttle website.

Having 10 years of proffessional experiance in writing "non-webbased" code i
thought that will not be that hard.
I think here it went wrong.

The only thing he want to do is integrating an external provided iframe into
his website and make that multilingual using some little flags that he puts
at the top of his site.

This is the src iframe src="provideroftheframe.php?lang=en"

So when he clicks for example a spanish flag the param lang should change to
ES , the france flag to FR...

Is this possible using a javascript and if so can someone provide me a
solution ; this has to be done without server side technologie

Kind regards

J.
 
V

VK

This is the src iframe src="provideroftheframe.php?lang=en"

So when he clicks for example a spanish flag the param lang should change to
ES , the france flag to FR...

You don't need any Javascript for that, plain old HTML will suffice:

<iframe name="MyIFrame" src="provideroftheframe.php?lang=en">

<a href="provideroftheframe.php?lang=es" target="MyIFrame"><img
src="Spain.gif"></a>
 
J

Jo Claes

Hi,

and what if you have two params fe.
provideroftheframe.php?lang=en&category=1
clicking flag will change the language and a dropdown list using the
category ?

Kind regards
 
V

VK

Hi,

and what if you have two params fe.
provideroftheframe.php?lang=en&category=1
clicking flag will change the language and a dropdown list using the
category ?

Then you have a different solution, obviously. The previous one has
been given for what you asked in the original post.

For more complicated situations you have to decide if:
a) all possible URL parameters can be stored in form controls.
b) URL parameters cannot be hardcoded but must be calculated client-
side depending on user input.

In case a) you still don't need any Javascript:

<iframe name="MyIFRAME" src="provideroftheframe.php?lang=en">

<form target="MyIFRAME" method="GET" action="provideroftheframe.php">
<input type="text" name="lang" value="es">
<input type="text" name="category" value="1">
<input type="submit">
</form>

Obviously you can use any needed control types, text boxes are used
only for simplicity.

In case b) you need to query form controls for current values,
validate the input, make the needed calculations based on it, generate
URL string and assign iframe's window.href property to get new page.
An abstract description of all these operations would be effectively
equal to a set of posts with Javascript introductory lessons; thus if
the variant b) is your case then please post the entire page your are
working with with the exact explanation what form controls do you
want to use for URL generation and by what algorithm. A demonstration
of your initial attempt to solve the problem - even if failed - would
be also much appreciated.
 
A

ASM

Jo Claes a écrit :
The only thing he want to do is integrating an external provided iframe into
his website and make that multilingual using some little flags that he puts
at the top of his site.

<a href="myPage.html.en" target="myIframe">
<img src="en_flag.jpg" alt="english" title="english">
</a>
<a href="myPage.html.sp" target="myIframe">
<img src="sp_flag.jpg" alt="spanish" title="spanish">
</a>
<a href="myPage.html.fr" target="myIframe">
<img src="fr_flag.jpg" alt="french" title="french">
This is the src iframe src="provideroftheframe.php?lang=en"

So when he clicks for example a spanish flag the param lang should change to
ES , the france flag to FR...
Is this possible using a javascript and if so can someone provide me a
solution ; this has to be done without server side technologie

If really he uses php and variable to set language
and absolutly wants to be dependent of JS :

function country(flag) {
document.myIframe.location.href = 'provideroftheframe.php?lang='+flag;
}

<img src="en_flag.jpg" alt="english" onclick="country('en');">
<img src="sp_flag.jpg" alt="spanish" onclick="country('sp');">
<img src="fr_flag.jpg" alt="french" onclick="country('fr');>


or (better) :

function country(flag) {
document.myIframe.location.href = 'provideroftheframe.php?lang='+flag;
return false;
}

<a href="myPage.html.en" target="myIframe"
onclick="return country('en');">
<img src="en_flag.jpg" alt="english" title="english">
</a>
<a href="myPage.html.sp" target="myIframe"
onclick="return country('sp');">
<img src="sp_flag.jpg" alt="spanish" title="spanish">
</a>
<a href="myPage.html.fr" target="myIframe"
onclick="return country('fr');">
<img src="fr_flag.jpg" alt="french" title="french">
</a>
 

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

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,428
Latest member
RosalieQui

Latest Threads

Top