473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

javascript:LaunchApp and php

JZ
I hope there is someone out there that can suggest a solution to my
problem.
So here we go:

$command="myapp.exe -P d:\mydir\mySubDir";
echo "<td><a href=\"javascript:LaunchApp('$command')\">blah</a></td>";

This works fine. But when 'mySubDir' becomes 'my Sub Dir' myapp
requires quotes:
myapp.exe -P "d:\mydir\my Sub Dir"

So I tried (along with several variations):
echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P "d:\mydir\my
Sub Dir"')\">blah</a></td>";

echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P \"d:\mydir\my
Sub Dir\"')\">blah</a></td>";

Whatever I tried my string ends after -P

Regards,
JZ
Jul 17 '05 #1
7 2604

JZ wrote:
I hope there is someone out there that can suggest a solution to my
problem.
So here we go:

$command="myapp.exe -P d:\mydir\mySubDir";
echo "<td><a href=\"javascript:LaunchApp('$command')\">blah</a></td>";
This works fine. But when 'mySubDir' becomes 'my Sub Dir' myapp
requires quotes:
myapp.exe -P "d:\mydir\my Sub Dir"

So I tried (along with several variations):
echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P "d:\mydir\my
Sub Dir"')\">blah</a></td>";

echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P \"d:\mydir\my
Sub Dir\"')\">blah</a></td>";


Did you try:
$command = 'myapp.exe -P "d:\mydir\my Sub Dir"';
echo '<td><a href="javascript:LaunchApp(' . "'" . $command . "'" .
')">blah</a></td>';

You can also try:
$command = 'myapp.exe -P d:\mydir\' . urlencode('my Sub Dir');

Ken

Jul 17 '05 #2


I tried the following:
[$project is the directory from my example]

$command1='si diff -g -P "'.$project.'" -r '.$previousRev.' -r '.$rev.'
'.$shortFile;

echo '<td><a href="javascript:LaunchApp('.
"'".$command1."'".
')">'."$shortFileAndRev</a><br>$project</td>";

All I see is:
javascript:LaunchApp('si diff -g -P

Jul 17 '05 #3
JZ wrote:
$command="myapp.exe -P d:\mydir\mySubDir";
echo "<td><a href=\"javascript:LaunchApp('$command')\">blah</a></td>";

This works fine.
Only for a bizarre definition of 'fine'. It might give the
impression of working in a handful of situations, but it
fails in a bucketload and it's by no means correct.

Strictly speaking, the resulting construct is not HTML
because, on two accounts, the href value is not a URI.
First, the value contains characters which are disallowed in
URIs: spaces and backslashes, the percent-encodings of
which are %20 and %5C respectively. Second, the javascript
scheme has not been registered, and so even if you were to
percent-encode the disallowed characters, the construct
would still violate the HTML spec.

See c.i.w.a.html for discussions on the more practical
downsides of the javascript pseudo-protocol in hrefs, and on
why you should use event handlers instead.
But when 'mySubDir' becomes 'my Sub Dir' myapp
requires quotes:
myapp.exe -P "d:\mydir\my Sub Dir"
Inside a double-quoted attribute value, a double-quote can
be represented by the entity reference &quot; or the
character references " and &#x22;. Double-quotes are
disallowed in URIs, however, so they must be percent-encoded
with %22.
So I tried (along with several variations):
echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P "d:\mydir\my
Sub Dir"')\">blah</a></td>";

echo "<td><a href=\"javascript:LaunchApp('myapp.exe -P \"d:\mydir\my
Sub Dir\"')\">blah</a></td>";

Whatever I tried my string ends after -P


In the first example, yes; you get a parse error because the
double-quote after the '-P' ends the first string of the
echo. For a double-quote to appear in a double-quoted
string, you must escape it with a backslash.

If you look closely, you'll see the string in the second
example is exactly what you asked for: The escaped double-
quote after the '-P' closes the href attribute, and by dint
of reasonable error recovery, everything up to the
next '>' is ignored. Proof: View the source.

Reasonableness isn't a requirement of the spec however.

Slainte! & HAGW!

--
Jock
Jul 17 '05 #4


I agree that what I am trying to do could be flawed. After all
sometimes we need to do what is not exactly our area of expertise. I
don't know much about php or html but I need to fix this bug. If there
is a better way to invoke my app I would be more than happy to hear it.

JZ

Jul 17 '05 #5
To followup-to an article using G2, go to 'show options' and
*then* 'reply', interleaving your comments below those to
which you are responding and deleting superfluous text.
Please do not just 'reply'.

[Anonymous -- J.D.] wrote:
If there is a better way to invoke my app I would be more than
happy to hear it.


Sorry, I don't know what you're trying to do. 'Invoke my
app' doesn't mean much to me.

However, if you're trying to call a Javascript function, the
recommended way is through the intrinsic events, not the
href. See

http://www.jibbering.com/faq/#FAQ4_24

--
Jock
Jul 17 '05 #6
For what is worth here is my solution to my problem:

$command1='si diff -g -P \\\''.ltrim($project).'\\\' -r
'.$previousRev.' -r '.$rev.' '.$shortFile;

echo '<td><a href="javascript:LaunchApp('.
"'".$command1."'".
')">'."$shortFileAndRev</a><br>$project</td>";

Jul 17 '05 #7
This if funny. My browser doesn't display the solution properly.
So here we go:

jz******@rogers.com wrote:
For what is worth here is my solution to my problem:

$command1='si diff -g -P \\\''.ltrim($project).'\\\' -r
'.$previousRev.' -r '.$rev.' '.$shortFile;

echo '<td><a href="javascript:LaunchApp('.
"'".$command1."'".
')">'."$shortFileAndRev</a><br>$project</td>";


Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: forum7 | last post by:
I need some immediate guidance with an error I am facing using an ActiveXObject to instantiate a DLL and use the object to launch a command on the local client. I use this great DLL called...
3
by: JavaScripter | last post by:
hi everyone, i am using sql server 2005 to connect to a vb6 or earlier version app. i appear to be having a problem with the connection string - i have been to http://www.connectionstrings.com ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.