PDA

View Full Version : How to Target Frame in this script



Yukoner
11-08-2006, 04:23 PM
:confused:
I would like to use the menu at the link below, but need it to target a frame for the purpose I want. Can someone help? I tried what I found in the FAQs and got it to target the "main" frame, but it insisted on putting the URL address in text on the initial frame.

http://www.dynamicdrive.com/dynamicindex1/combodescribe.htm

12345c
11-09-2006, 07:24 PM
You have to add attribute in form tag:

<form name="form1" target=name_of_frame>


...
<iframe name=name_of_frame ...>
or <frame name=name_of_frame ...>

Yukoner
11-09-2006, 08:58 PM
:)
I will try this when I get home.

I take it the latter part goes at the end of the form prior to </form>

Yukoner

Yukoner
11-10-2006, 02:25 AM
You have to add attribute in form tag:

<form name="form1" target=name_of_frame>


...
<iframe name=name_of_frame ...>
or <frame name=name_of_frame ...>

Tried this...didn't work :-(

Put into form as above. Put <frame name...> into head of target frame.

No luck. Any other suggestions

jscheuer1
11-10-2006, 05:53 AM
The frame name doesn't go in the head. It goes directly in the frame or iframe tag itself, just as shown. A more complete example:


<frame name="main" src="main.htm" frameborder="1">

or:


<iframe name="iframe_one" src="content_one.htm" width="300" height="250"></iframe>

Yukoner
11-11-2006, 12:47 AM
The frame name was already there in the HTML Frames Page and still could not target it. If I use

javascript:parent.myframe.location=http://www.mypage.com (the happy face is replacing a "colon p"
it will target the frame needed but then leaves the original page blank except puts the text http://www.mypage.com on it.

jscheuer1
11-11-2006, 04:38 AM
The frame name was already there in the HTML Frames Page and still could not target it. If I use

javascript:parent.myframe.location=http://www.mypage.com (the happy face is replacing a "colon p"

Use the advanced editor and disable smilies.


it will target the frame needed but then leaves the original page blank except puts the text http://www.mypage.com on it.

OK, almost home. You need to quote literals in that type of statement and using the href object is good form (will keep you out of trouble in certain situations):


javascript:parent.myframe.location.href='http://www.mypage.com'

But, used as an href, it will still be active on the 'sending' page just as you describe. Used in other situations, the javascript: convention is not required. The best method in a link is (requires no javascript at all):


<a href="http://www.mypage.com" target="myframe">My Page</a>

or, in raw code (javascript enabled required):


parent.myframe.location.href='http://www.mypage.com'

Or, if you must use an onclick javascript event in a link (javascript assists but is not required to be enabled):


<a href="http://www.mypage.com" target="myframe" onclick="parent.myframe.location.href=this.href;return false;">My Page</a>

or (also javascript assists but is not required to be enabled):


<a href="http://www.mypage.com" target="myframe" onclick="window.open(this.href,this.target);return false;">My Page</a>

There really are many, many ways to do this in raw code or as an event. The above is only a partial listing.

Yukoner
11-11-2006, 04:58 AM
Thanks So much John. I appreciate your time very much.

There is something in the drop down menu I want to use that keeps regular methods from targetting the frame I want. The link to the script is

http://www.dynamicdrive.com/dynamicindex1/combodescribe.htm

It has a field "newwin" and works fine to open the target in a new window, but I just can't get it to open in the target frame. Other menu scripts work fine right along side it, regular links, etc. It is just this one menu that I can't get to target the main frame

jscheuer1
11-11-2006, 05:17 AM
I see your problem, what you were using was being interpreted by function jumptolink(what) to mean:


window.location=javascript:parent.myframe.location='http://www.mypage.com'

Use this function jumptolink(what) instead:


function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else if (selectedopt.getAttribute("target")&&selectedopt.getAttribute("target")!=''&&selectedopt.getAttribute("target")!='_self')
window.open(selectedopt.value, selectedopt.getAttribute("target"))
else
window.location=selectedopt.value
}

and just specify the target in the option like so:


<option value="http://www.codingforums.com" target="myframe">Coding Forums</option>

Yukoner
11-11-2006, 06:20 AM
the "newwin" will still open a new window, but everthing else still openes in the original frame and not the target frame.

I put in the "function jumptolink" changes you suggested and added the target="myframe", but to no avail. The new page still opens in the original frame.

Will try again tomorrow after I get done with my clients. If you have any other suggestions I am more than happy to try them and am grateful for the info.

Yukoner

jscheuer1
11-11-2006, 06:29 AM
Works here.

Yukoner
11-11-2006, 03:16 PM
Thanks John. If it works for you it will work for me. I will start fresh and include your suggestions. I appreciate the time and effort you have taken.

Yukoner

jscheuer1
11-11-2006, 06:43 PM
If you continue having trouble, I will put up a demo for you to look at.

Yukoner
11-11-2006, 10:36 PM
Tried again and worked like a charm. Thanks again.

Yukoner
11-14-2006, 11:13 PM
Hi John.

If you want to see the application of this script the URL is http://www.ywhn.org/articles.htm . The only thing I would like to change now is the font for the button and the <option> variables. If I can't, not too drastic but would be nice.

Thanks again for your time.

Yukoner

jscheuer1
11-15-2006, 04:33 AM
In the head of the page - the rule (blue) may be made a part of an existing stylesheet on or linked to the page:


<style type="text/css">
.sel1 {
font-family:'comic sans ms', sans-serif;
}
</style>

In the markup:


<select class="sel1" name="select1" si . . .

and:


<input class="sel1" type="bu . . .

Yukoner
11-15-2006, 05:01 AM
:D
Thanks again John. I was able to take the css you suggested for the <head> and by trying the inputs in different spots found a correct way to change the fonts.

As you can tell, this is an area where I am at a total loss. Have a wonderful day

Yukoner