Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: How to Target Frame in this script

  1. #1
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How to Target Frame in this script


    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/dynamici...bodescribe.htm

  2. #2
    Join Date
    Dec 2005
    Location
    Moscow, Russia
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You have to add attribute in form tag:
    Code:
    <form name="form1" target=name_of_frame>
    
    
    ...
    <iframe name=name_of_frame ...>
    or <frame name=name_of_frame ...>

  3. #3
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Thanks 12345c


    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
    Last edited by Yukoner; 11-09-2006 at 11:41 PM.

  4. #4
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Nope, couldn't get it to work

    Quote Originally Posted by 12345c
    You have to add attribute in form tag:
    Code:
    <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

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    HTML Code:
    <frame name="main" src="main.htm" frameborder="1">
    or:

    HTML Code:
    <iframe name="iframe_one" src="content_one.htm" width="300" height="250"></iframe>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Already there and still unsuccessful. See below

    The frame name was already there in the HTML Frames Page and still could not target it. If I use

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

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Yukoner
    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):

    Code:
    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):

    HTML Code:
    <a href="http://www.mypage.com" target="myframe">My Page</a>
    or, in raw code (javascript enabled required):

    Code:
    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):

    HTML Code:
    <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):

    HTML Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Not there yet...but close I hope

    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/dynamici...bodescribe.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

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I see your problem, what you were using was being interpreted by function jumptolink(what) to mean:

    Code:
    window.location=javascript:parent.myframe.location='http://www.mypage.com'
    Use this function jumptolink(what) instead:

    Code:
    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:

    HTML Code:
    <option value="http://www.codingforums.com" target="myframe">Coding Forums</option>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Nov 2006
    Location
    Whitehorse, Yukon
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Nope, not yet

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •