Forum Moderators: open
<a href="../pics/pan1.jpg" onClick="window.open('pic.jpg','pan','toolbar=no,location=no,directories=no'); return false"><span style="font-size:10pt">(Click here to view in seperate window)</span></a>
This worked fine with one problem. When I click on the second link the focus does not shift to the window, it stays with the original. To solve this I tryed writing a function like this:
<script type="text/javascript">
function open(num) {
window.open('../pics/pan'+num+'.jpg','pan','toolbar=no,location=no,directories=no')
pan.focus()
}
</script>
Then referenced it in the onClick like this:
<a href="../pics/pan1.jpg" onClick="open('1'); return false"><span style="font-size:10pt">(Click here to view in seperate window)</span></a>
This went terribly wrong. Now when either link is clicked on the entire page turns white sometimes after freezing for several seconds. Help me
<script type="text/javascript">
function MYopen(url,name) {
window.open(url,name,'toolbar=no,location=no,directories=no');
pan.focus();
return false;
}
</script>
<span style="font-size:10pt"><a href="../pics/pan1.jpg" onclick="return MYopen('../pics/pan1.jpg','pan');">(Click here to view in seperate window)</a></span>
An alternative to that onclick, since the path is the same as the link's href would be to use this.href:
<span style="font-size:10pt"><a href="../pics/pan1.jpg" onclick="return MYopen(this.href,'pan');">(Click here to view in seperate window)</a></span>
<script type="text/javascript">
function MYopen(url,name) {
window.open(url,name,'toolbar=no,location=no,directories=no');
pan.focus();
return false;
}
</script>
My bad, actually, that should be more like:
<script type="text/javascript">
var myWin;
function MYopen(url,name) {
myWin = window.open(url,name,'toolbar=no,location=no,directories=no');
myWin.focus();
return false;
}
</script>
<html>
<head>
<script type="text/script">
<!--
var part;
function picwin(url,name) {
part = window.open(url,name,'toolbar=no,location=no,directories=no, width=300, height=310');
part.focus();
return false;
}
-->
</script>
</head>
<body>
<table id="layout">
<tr>
<td><p class="bold">Type One Parts</p><img src="../pics/part1.jpg"><br />
<a href="../pics/part1.jpg" onclick="return picwin(this.href,'part')"><span style="font-size:10pt">(Click here to view in seperate window)</span></a></td>
<td><p class="bold">Type Two Parts</p><img src="../pics/part2.jpg"><br />
<a href="../pics/part2.jpg" onClick="return picwin(this.href,'part')"><span style="font-size:10pt">(Click here to view in seperate window)</span></a></td>
<td><p class="bold">Type Three Parts</p><img src="../pics/part3.jpg"><br />
<a href="../pics/part3.jpg" onClick="return picwin(this.href,'part')"><span style="font-size:10pt">(Click here to view in seperate window)</span></a></td>
</tr>
</table>
</body>
</html>
[edited by: tedster at 3:52 am (utc) on Jan. 5, 2009]
[edit reason] make link text generic [/edit]
<script type="text/script"> //<---- it's a script yeah, but what kind? (script should be javascript) this was the big problem
<!--
var part;function picwin(url,name) {
part = window.open(url,name,'toolbar=no,location=no,directories=no, width=300, height=310');
part.focus();
return false;
}
--> //<---- That should look like: //--> //or take those html comments out altogether
</script>