473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Changing the Url of an Iframe with a selection box

Hello
I have been wrestling with a problem, I am trying to change the url of
an Iframe from a simple selection box, once the user selects the
desired url they wish to visit from the main page the iframe then loads
the url while not affecting the main page. I am using the onchange
event of the select tag to drive the javascript function hopefully
passing the value of the selection wich in this case is the url to the
independant script wich will in turn will change the src of the iframe
from the default page that is loaded when first viewing the page.One
question I have is would it be better to use the onload event to set
the initial src then use the onchange event form the select to change
the src or staticly set the src then use the onchange event to change
it? below is an example of my code so far. Also currently whenever I
try to pass teh value to the script I get an object expected error and
nothing happens.Bear in mind I know enough C++ to make myself dangerous
and can stay on top javascript to a point but right now I am just lost.
just need a nudge in the right direction at this point please :D

<select name="sites" id="sites" onchange="changesite()">
<option value=" "> </option>
<option value="http://www.nanpa.org">NANPA.org</option>
<option value="http://www.google.com">Google.com</option>
<option
value="http://www.spywarewarrior.com">spywarewarrior.com</option>
</select>

Function changesite(value)
{
var newsite = value;
document.frames['websites'].src = newsite;
}

Mar 29 '06 #1
3 2815
forgot to post my irame code also to show the full context

<iframe name="websites" id="websites" width="100%" height="100%"
src="http://www.google.com" scrolling="yes"></iframe>

Mar 29 '06 #2
Jim
John,
This should work for you:
<body bgcolor="#FFFFFF" text="#000000">
<form name="selection">
<select name="sites" id="sites"
onchange="document.frames['websites'].location=this.value">
<option selected>Pick a Site</option>
<option value="http://www.yahoo.com">Yahoo.com</option>
<option value="http://www.google.com">Google.com</option>
<option value="http://www.ebay.com">Ebay.com</option>
</select>
</form>
<hr>
<iframe name="websites" id="websites" width="80%" height="60%"
src="http://www.ask.com" scrolling="yes"></iframe>
</body>

Mar 29 '06 #3
Thnx for the heads up, I had though along those lines but had dismissed
it since I was focusing ont he script and making it harder for myself

Mar 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Blue Streak | last post by:
Hello, Folks! I am trying to create dynamic content for an IFrame object within an ASPX page. I did not want to try and pull its content from another page. Previously in ASP.Classic I would use...
2
by: Rob | last post by:
Hi Gang: I have a page that loads a remote page into an IFRAME. I don't have any control over this remote page though the page is owned by the same company I work for. The problem is that all...
4
by: Laphan | last post by:
Hi The god that is Martin Honnen gave me a great tip to DOM/JS some HTML data into an iframe, but I need to make sure that the iframe is ready to take it before I paste it in. At the moment,...
4
by: libsfan01 | last post by:
hey this code wont work for my iframe in safari, i cant change the page by changing the src with js: <script language="javascript"> function loadcontent(page) {...
3
by: bulldog8 | last post by:
I am having problems with changing a frames source file for Mozilla (1.5.0.4). The followig code works for IE: <script type="text/javascript"> var imgP = new Image(); function...
5
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I...
4
by: linuskamb | last post by:
I have a problem which is a slight twist on discussions I have seen previously here and elsewhere. I have a form with an input select combo box whose target is an internal static iframe. The form...
1
by: appleseed | last post by:
I'm having some problems on IE with a small editor I'm building. The source of the problem is the following: Consider having an iFrame with designMode="on" in which you select some text. When...
5
by: iuniamadalina | last post by:
Hi! i have a html page with a iframe. I want to be able to select some text from iframe and when i push a button outside the iframe the selected tet shoul be copied in a text field ( the text field...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.