window.open

A

Anonymous

Guest
Hello,

I want to be able to open a page using a variable instead of a direct link. Example:

this will work:

<input name="down" type="button" onClick="window.open('C:/download/file.txt')" value="Click Me">

but what I want to do is make the "C:/download/file.txt" a php variable like <?php $location="C:/download/file.txt" ?>

and then;

onClick=("$location")

but I can not get this to work. Any ideas ?
 
I don't know if you can open local files with javascript...
Anyway:
It should work:
Code:
<?php
$location = "anything";
echo "<input name='down' type='button' onClick='window.open(\"". $location ."\")' value='Click Me'>";
?>
 
ah..of course..I didnt think of that..thanks (I tested it and it works great)
 
Back
Top