PDA

View Full Version : Opening a link in new window (script action) - weird


ryanm123
11-05-2007, 01:18 PM
Hey all.

I have a html file with a script action in it.

I have 3 html files (index.html, file1.html and file2.html)

I want to run the index.html in a Joomla Wrapper (kinda like a IFRAME).

But there is a clickable link in this file, but when somebody clicks it, it opens the referencing file (lets say file1.html) in a new window. It basically breaks out of the wrapper/iframe.

This is the code:

<script>
function cont1(){
top.location.href="file1.htm";
}
function cont2(){
top.location.href="file2.htm";
}
</script>


Now the guys over at the joomla forum don't have a clue as what to do...


One guy mentioned that I should try the following:

<script>
function cont1(){
top.location.href="file1.htm" target="_self";
}
function cont2(){
top.location.href="file2.htm" target="_self";
}
</script>

But this only makes the link "inactive" - the referencing file does not want to open at all. :confused:


Then another guy said something interesting.
He said it might be that there is an attribute in the file1.htm and file2.htm file that causes them to WANT to open in a new window.

I would really appreciate some feedback on this.

I'm not a coder at all, but I'm willing to follow anybodies advice so I can fix this problem. :rolleyes:

Mr J
11-05-2007, 01:50 PM
Try just

location.href="file1.htm"

kosstr12
11-05-2007, 02:05 PM
I know to make a regular link make a new window, this is the code:

<a href="link.html" target="_blank"> Link Text</a>

ryanm123
11-05-2007, 02:24 PM
Thanks Mr J

That worked!