Hi,

In search_results.php I have a variable named $path which display something like: C:/documents/personal/home.doc

I would like to create a button that link to a new window
which is going to display: C:/documents/personal/home.doc

Right now is being displayed in search_results.php like this:

echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$path</font></td>";

Kako,

Easiest way is to use an <a> tag:

echo "<a href="$path" target="_new">Click Me</a>";

You can use <button> if you want but you then have to use window.open etc. etc. because <button> was included in the HTML spec for form submission as an alternative to <input type="button"> , <input type="select"> or <input type="reset"> . It isn't set up to hyperlink by default so you have to write more code.

If you want the <a> to render a bit like a button then you can style it with CSS, eg:

a.button { width:100px; line-height:2.0em; border:1px solid #999; border-bottom-width:2px; border-right-width:2px; background-color:#e0e0e0; text-align:center; font-family:verdana; font-size:9pt; text-decoration:none; color:#000; }
a.button:visited { color:#000; }
a.button:hover { background-color:#e0f0f0; color:#006060; }

Then you just have to set class="button" in the <a> tag.

Airshow

Kako,

Easiest way is to use an <a> tag:

echo "<a href="$path" target="_new">Click Me</a>";

You can use <button> if you want but you then have to use window.open etc. etc. because <button> was included in the HTML spec for form submission as an alternative to <input type="button"> , <input type="select"> or <input type="reset"> . It isn't set up to hyperlink by default so you have to write more code.

If you want the <a> to render a bit like a button then you can style it with CSS, eg:

a.button { width:100px; line-height:2.0em; border:1px solid #999; border-bottom-width:2px; border-right-width:2px; background-color:#e0e0e0; text-align:center; font-family:verdana; font-size:9pt; text-decoration:none; color:#000; }
a.button:visited { color:#000; }
a.button:hover { background-color:#e0f0f0; color:#006060; }

Then you just have to set class="button" in the <a> tag.

Airshow

Hi, I think I don't explain too well.

I want something like this:

<FORM>
<INPUT type="button" value="New Window!" onClick="window.open('http://www.pageresource.com/jscript/jex5.htm','mywindow','width=400,height=200')">
</FORM>

http://www.pageresource.com/jscript/jwinopen.htm

But instead of display "This is a new window", I would like it to display the content of $path variable.

Kako,

Where do you want to display $path - in the button or in the new window?

Airshow

In the new window.

Kako,

The requested url is available to your server-side scripting language (eg php) and to javascript.

In php use one of the following, depending on exactly what you want:

  • $_SERVER,
  • $_SERVER,
  • $_SERVER,
  • $_SERVER

See here for details. Other server-side languages provide similar.

Client-side, Javascript makes the url available in the form of the window.location object. Its properties are:

  • window.location.hash
  • window.location.host
  • window.location.hostname
  • window.location.href (the complete url)
  • window.location.pathname
  • window.location.port
  • window.location.protocol
  • window.location.search

See eg, here for details. Use document.write() or DHTML techniques to display any of these.

Hence, there are two basic mechanisms for displaying the information you require.

Airshow

Kako,

The requested url is available to your server-side scripting language (eg php) and to javascript.

In php use one of the following, depending on exactly what you want:

  • $_SERVER,
  • $_SERVER,
  • $_SERVER,
  • $_SERVER

See here for details. Other server-side languages provide similar.

Client-side, Javascript makes the url available in the form of the window.location object. Its properties are:

  • window.location.hash
  • window.location.host
  • window.location.hostname
  • window.location.href (the complete url)
  • window.location.pathname
  • window.location.port
  • window.location.protocol
  • window.location.search

See eg, here for details. Use document.write() or DHTML techniques to display any of these.

Hence, there are two basic mechanisms for displaying the information you require.

Airshow

Ok but that for pass an URL. What I has been trying to do is pass
$path which contain for example: C:/documents/personal/home.doc

I tried something like:

echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'><a href="javascript:void(0);" onclick="window.open('path.php?path= "<?$path;?>"','Path','width=333,height=490,toolbar=no,scrollbars=yes')">View Path</a>
</font></td>";

That's something I'm trying but I'm being unable. That's code give me a lot of error. But that's the idea.

Kako,

You could make that work, but there's no point. You're just telling the page about something it already knows - namely itself! My previous post refers.

Airshow

Kako,

You could make that work, but there's no point. You're just telling the page about something it already knows - namely itself! My previous post refers.

Airshow

Ok, there is a confusion. I went able to make it work.
Thanks for trying!


Here is:

echo "<td align=left bgcolor=$bgcolor id='directory'>&nbsp;<font face='Verdana' size='2'><a href=\"#\" onclick=\"window.open('path.php?value=$path','no','scrollbars=yes,width=550,height=400');\">View Path</a></font></td>";

And in path.php just:

<?php
echo $_REQUEST['value'];
?>

OK, and now try:

<%= $_SERVER['REQUEST_URI']; %>

or

<script>document.write(location.href);</script>

at the same place on the page.

Airshow

This question has already been answered. Start a new discussion instead.