www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to Close Frame in Frameset w/out Losing Page

  1. #1
    Join Date
    Jul 2009
    Location
    Worcester, MA
    Posts
    3

    Lightbulb How to Close Frame in Frameset w/out Losing Page

    What can Diigolet do but Bing and Google Image search cannot do?

    Close their frame and remember the page you were on.

    Background:
    I am making a music player for a client that will stay on the page no matter what page he is going to and not be interrupted by the user's browsing. I decided to implement frames. Now the hard thing is how to close the frame the music player is on without disturbing the page that the user was on. I have tried a few little things with no success at all.

    Request:
    A javascript code in or along side of a link html tag. Such as...

    Code:
    <a href="javascript:CODE" target="_top">[X]</a>
    or

    Code:
    <script>
    function closeframe() {
    CODE
    }
    </script>
    <a href="javascript:closeframe()" target="_top">[X]</a>

    Please help. Thanks.

  2. #2
    Join Date
    Jul 2009
    Location
    Worcester, MA
    Posts
    3

    Got It!

    Alright, I figured it out. To close a frame and stay on the URL of the main frame, I had to get the proper value for the URL of the main frame as it changes. Once I found that out, I set the top frame URL equal to that URL. So simple, but I've never seen this code anywhere. Heck, like I said, Google and Bing haven't figured it out... maybe there's a browser issue?

    Whatev's, here it is...

    Code:
    <script>
    var mainloc = window.parent.frames["NAMEOFFRAME"].document.location
    function clsefrme() {
    	window.top.document.location = mainloc
    }
    </script>
    <a href="#" onclick="javascript:clsefrme();return false">[X]</a>

  3. #3
    Join Date
    Jul 2009
    Location
    Worcester, MA
    Posts
    3
    This also works (just tried it in MF 1.5):

    Code:
    <a href="javascript:window.top.document.location=window.parent.frames['NAMEOFFRAME'].document.location">[X]</a>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles