Board Logo

Open Link in a new window ?
quinnrd - 3/27/2003 at 04:17 AM

I have images scrolling and would like to pop-up a new window when I detect on the image. With the following code I get "Error On Page" which does not help me much. Following is the html I am passing in through the control file. Any help would be appreciated. Thanks in advance..
code:
<html>

<head>
<script language="javascript" src="ts_files/scroll.js"></script>
</head>
<! start window popup >

<body>
<script language="JavaScript">
function newWindow(mypage,myname,w,h,features) {
if(screen.width){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
}else{winl = 0;wint =0;}
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
</script>

<! end window popup >

<a href="JavaScript:newWindow
('feature1.html','popup',725,200,'')"alt="Featured Movie 1">
<img align="left" src="wind.jpg" alt="Featured Movie" border="0"></a>

<!--<a href="feature1.html"><img align="left" src="wind.jpg" alt="Featured " border="0"></a>-->

</body>
</html>


nik - 4/1/2003 at 07:21 AM

The reason of the problem you have described is that Scroller instance is built into inline frame (iframe) HTML object, consequently, variables (and functions as well) declared in parent document are not available by their original references, but with parent. prefix only. So the solution is either to specify link href as javascript:parent.newWindow(...) or just move newWindow function declaration to Scroller template (default scroll.tpl0.js) file.


araczynski - 4/1/2003 at 04:05 PM

Any chance you'd take the time to tell me the code to add to the Scroller template file to make new windows pop up in a new browser window automatically?

TIA
Andy

Quote:
Originally posted by nik
The reason of problem you have described is that Scroller instance is
built into inline frame (iframe) HTML object, consequently, variables
(and functions as well) declared in parent document are not available
by their original references, but with parent. prefix only. So the
solution is either to specify link href as
javascript:parent.newWindow(...) or just move newWindow function
declaration to Scroller template (default scroll.tpl0.js) file.


nik - 4/2/2003 at 09:03 AM

What do you mean saying "automatically"?


araczynski - 4/2/2003 at 02:19 PM

Here's the whole story... I would love to use your scroller on our educational agency website, but the only problem is that some of the news which we woudl be scrolling contain links, which of course doesn't work too well since this is an iframe solution. So I figured I couldn't use the software because we needed to show the links in the main frame and not inside the little scroller news.

So the 2nd message above seemed to give me some hope in that some code can be placed in the scroll.tpl?.js file (or a different one) that would automatically open each link in a whole new window, or perhaps in a different frame.

Clear as mud? ;)

TIA

Quote:
Originally posted by nik
What do you mean saying "automatically"?


nik - 4/3/2003 at 06:54 AM

To open links in main frame just add target="_parent" to all links inside the scroller. For example: <a href="mypage.htm" target="_parent">my page</a>


araczynski - 4/3/2003 at 02:14 PM

dagnabit, i thought i tried that :(
that was the solution, thank you very much :)

Quote:
Originally posted by nik
To open links in main frame just add target="_parent" to all links inside the scroller. For example: <a href="mypage.htm" target="_parent">my page</a>


Denis La Bine - 7/11/2003 at 08:10 AM

it sounds very interesting


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/