|
Posted by Toby Inkster on 12/03/07 11:58
Bill Burke wrote:
> <td height="19" width="338"><a href="#" onClick="MyWindow=window.open($bigPIC
> ,'MyWindow',$bigWIDTH,$bigHEIGHT,'toolbar=no,location=no,directories=no,
> status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100'); return
> false;">> click here for a larger view <</a></td>
>
> I am setting the value for the three variables in the javascript portion of the
> HMTL page:
>
> var $bigPIC="images/big_bock.jpg"
> var $bigWIDTH="width=530px"
> var $bigHEIGHT="height=435px"
Ummm... that's not at all how Javascript works.
Firstly, Javascript variables cannot begin with a dollar sign. Should be:
var bigPIC="images/big_bock.jpg";
var bigWIDTH="width=530px";
var bigHEIGHT="height=435px";
Secondly, you can't then drop them into some HTML and expect them to do
something -- Javascript variables only "have scope" within script blocks.
So you want something like:
<script type="text/javascript">
document.write('<td height="19" width="338">');
document.write('<a href="'+bigPIC+'" target="MyWindow" ');
document.write('onClick="MyWindow=window.open(this.href, this.target, ');
document.write('\''+bigWIDTH+','+bigHEIGHT+',toolbar=no,location=no,');
document.write('directories=no,status=no,menubar=no,scrollbars=no,');
document.write('resizable=no,left=100,top=100\');return false;">')
document.write('> larger view <</a></td>');
</script>
Lastly, depending on how you calculated the value for "cImg" this would
probably be better/easier using server-side scripting.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
[Back to original message]
|