Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

frame targeting problem 1

Status
Not open for further replies.

retrositelover

Programmer
Oct 20, 2004
35
Hi,

I have a problem with a script I wanted to modify - might be interesting for others, so I post it here:

The original script is from - I wanted to use it in order to target to 5 frames (I called them 'surfareas', but they are Iframes), or (in another version of my homepage) to let Firefox open windows that work like frames. Every content page would have built in the new script, so that the visitors e.g. could decide in which instance they would like to open links from the current page (very comfortable if you have many links, and much more flexible than with conventional frames).

Actually, I'm not a good Javascript-coder, as you'll see when looking at my attempt to make the script work: -

there are 3 problems I can't solve:
- the script only works with new windows, but not with frames that are already open (very bad)
- I would like to be able to check 2 boxes, so that 2 frames would be targeted at the same time (or:)
- I would like to use radio buttons. for each radio button having another name, it seems not to be possible to limit the user's choice to only one checked radio button.

thanks in advance for any tip - all the best
Joerg
 
clickURL:

Code:
function clickURL( url )
    {
      var elem = false;
      try
      {
        elem = document.getElementById(currtarget);
      }
      catch(e)
      {}
      if (currtarget == "_self")
      {
        document.location = url;
      }
      else if (currtarget == "_top")
      {
        parent.document.location = url;
      }
      else if (currtarget == "_blank" || !elem)
      {
        window.open(url,"");
      }
      else
      {
	elem.src = url;
      }
    }

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
thank you :)
'window targeting' with onclick doesn't seem to work, but now, there's no error anymore
 
What do you mean, "window targeting with onclick"?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
I mean: if you just use the page (without existing frames), e.g. choose to target 'Surfarea2' (radio button 02) and then click on a link, the browser will open up a window now serving as frame 02. If the user keeps both windows open, he can click on any other link he clicks on in the first window, and the linked html page will open in 'Surfarea2'.

this works fine with normal hyperlinks, but not with the onclick-Event (free space in table cell)
 
Fixed:

Change
Code:
window.open(url,"");
to
Code:
window.open(url,currtarget);

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Great!

Just so you know, if the page selected is "external", the onclick will still open a new window.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top