tags:

views:

85

answers:

2

I am working on a project (Java, Swing) in which i have to pop a frame on clicking a hyperlink. but the coding for the frame and all its components is done in a different class and that hyperlink exists in a different class. what shall i do to pop that frame on clicking of the hyperlink please tell. thanks.

A: 

Update: Ignore all content below - after confirmation from OP, this is a Java Question not a JavaScript question.

Do you mean: "How do I break out of a frame when clicking on a hyperlink"?

If so, you need to set the target attribute of the link to "blank" or a not-yet-used-name within your page structure.

<a href="page4.html">This link stays in the frame</a>
<a href="page4.html" target="blank">This link pops out of the frame</a>
<p>Note: the 2nd link may open in a new window, or in a new tab
   depending on the user's preference settings.
</p>
<b>Other options</b>
<a href="page4.html" target="_parent">This link pops opens in the direct parent window</a>
<a href="page4.html" target="_top">This link pops opens in the most grandparent window</a>

Alternatively you could use JavaScript to call window.open(...);

If you have NO control over the generated HTML for the frame, you can still control where the links go by setting the target attribute programatically from the parent window as long as the 2 pages are from the same domain (for security reasons)

<script>
  var childFrameLinks = window.frames['yourFrameName'].document.links;
  for(var i=0;i<childFrameLinks.length;i++){
    childFrameLinks[i].target = 'blank';
  }
</script>
scunliffe
thanks a lot for helping but i am using java swings. using that i have to pop up a frame.
+1  A: 

Hi,

the coding for the frame and all its components is done in a different class and that hyperlink exists in a different class

What do you mean by that? Do you have another class which inherits from JFrame/Frame? Or do you create that Frame in a method of this class? If it is the latter why can't you call this method from outside? And how exactly are the classes which contain Frame and Hyperlink related to each other?

Please specify...

[Edit] Maybe the HyperlinkListener interface might help you.

Max

moxn