472,805 Members | 949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

loading a page in an inline frame

Hi
I have a code which works ok, except I would like to load the specified file
in an inline frame (I1) on the page instead of a whole new page if at all
possible - any help appreciated!
Here is the function in the <head>;

<script type="text/javascript">

function go()
{
location=document.forms[0].PropPage.value
}

</script>

.....and the code (form) which calls the function later on the page;

<form>
<p align="center">
<select id="PropPage" onchange="go()">
<option>-Select Property Type-
<option value="fincas.htm">Fincas
<option value="villas.htm">Villas
<option value="semidetached.htm">Semi-detached
<option value="apartments.htm">Apartments
<option value="plots.htm">Land plots
<option value="newdevelopments.htm">New Developments
</select>

Thanks in advance

Stumpy
Jul 20 '05 #1
1 5106
"StumpY" <st********************@hotmail.com> wrote in message
news:Bu****************@news-binary.blueyonder.co.uk...
I have a code which works ok, except I would like to load the
specified file in an inline frame (I1) on the page instead of
a whole new page if at all possible - any help appreciated!
Here is the function in the <head>;

<script type="text/javascript">

function go()
{
location=document.forms[0].PropPage.value
Unqualified "location" will be resolved as the location property in the
current global object (the window or frame on web browsers), if it
exists. To navigate an IFRAME with this type of statement you need to
assign the URL string to the location property in the IFRAME's global
object. The IFRAME's global object (window/frame) should be found in the
frames collection of the current window, either as a named property if
the IFRAME has a name attribute (or, an ID attribute, but not on so many
browsers), or as a numerically indexed property. So the location object
of the IFRAME may be referred to as:-

frames['iframeName'].location

frames[0].location

-for example (adjusting names/numbers to suite the context of the HTML
in use).

The value property of a SELECT element is not necessarily the best way
of getting the value of the currently selected option. It works on most
modern browsers (and is W3C HTML DOM specified) but the most reliable
method of reading the value of the selected option is to use the
selectedIndex property of the SELECT element to index its options
collection and read the value property of the option that is selected
directly:-

var sel = document.forms[0].PropPage;
if(sel.selectedIndex >= 0){ // -1 means no selection.
frames['iframeName'].location = sel.options[sel.selectedIndex].value;
}
}

</script>

....and the code (form) which calls the function later on
the page;
<form>
<p align="center">
<select id="PropPage" onchange="go()">
Have you tested this with keyboard navigation of the SELECT element?
Probably not, when you do so you might see a need to re-consider the use
of the onchange event, probably a separate "Go" button to actually do
the navigation would be better (or maybe a re-think of the whole idea
and the replacement of this SELECT element with a list of links
targeting the IFRAME)
<option>-Select Property Type-
This OPTION element has no value attribute, no associated URL. So, if it
is re-selected it will encourage the IFRAME to load a non-existent
resource. As this option has the index zero as slight modification to
the safety check I proposed above would avoid this option attempting to
navigate the IFRAME:-

if(sel.selectedIndex > 0){ //not -1 or zero.
...
<option value="fincas.htm">Fincas
<option value="villas.htm">Villas
<option value="semidetached.htm">Semi-detached
<option value="apartments.htm">Apartments
<option value="plots.htm">Land plots
<option value="newdevelopments.htm">New Developments
</select>


Also, none of this is going to work at all if the user has JavaScript
disabled or unavailable on their browser. That produces a dependency on
JavaScript that is not necessitated by the apparent desired behaviour of
this page.

Richard.
Jul 20 '05 #2

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

Similar topics

1
by: Alex Hunter | last post by:
is there a way to make one frame on a page load completely before the other frame starts loading?
2
by: Mike | last post by:
I have a typical two frame frameset. Menu frame on the left, load content on the right frame. Lately I have been having problems in that sometimes menu links will open a new window instead of...
1
by: RichardM | last post by:
I have the following HTML page (see bottom of message) that consists of a frame with two windows. The top window is always the menu, and the bottom window is by default a document named...
4
by: Bik | last post by:
I'm building a list of customer orders via ASP/VBscript. e.g: 51 John Doe $1,201.50 52 Jane Smith $ 500.00 53 Jim Miller $1,250.25 I want order numbers 51, 52, 53 hyperlinked...
6
by: Curious George | last post by:
I have a page that takes about 10 seconds to load the first time it is run. I would like to first display a little animated gif telling the user that the page is loading. How do I do this with...
3
by: markeboy | last post by:
I am wanting to control when a page is loaded using a separate class to manage when and how it should be loade My current implementation needs to set a property of the page programatically...
3
by: HK guy | last post by:
How to write a program that can check the web page loading time? Before I have written a browser that use IE as the core, but it does not support frame. Since the documentcomplete event will...
5
by: Jay Douglas | last post by:
I have a set of pages that inherit from a base class in the App_Code folder. The class looks something like: public class MyBaseClass : System.Web.UI.Page In various stages of the life cycle I...
1
by: John Smith | last post by:
Hey folks, Got a weird one for you that I think may just be a bug with Internet Explorer. I have a page that hosts an IFrame. When I call Javascript in my page to change the source of the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.