Connecting Tech Pros Worldwide Help | Site Map

javascript:LaunchApp and php

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 11:27 AM
JZ
Guest
 
Posts: n/a
Default javascript:LaunchApp and php

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

  #2  
Old July 17th, 2005, 11:27 AM
Ken Robinson
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php


JZ wrote:[color=blue]
> 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[/color]
href=\"javascript:LaunchApp('$command')\">blah</a></td>";[color=blue]
>
> 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>";[/color]

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

  #3  
Old July 17th, 2005, 11:27 AM
jzgoogle@rogers.com
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php



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

  #4  
Old July 17th, 2005, 11:27 AM
John Dunlop
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php

JZ wrote:
[color=blue]
> $command="myapp.exe -P d:\mydir\mySubDir";
> echo "<td><a href=\"javascript:LaunchApp('$command')\">blah</a></td>";
>
> This works fine.[/color]

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.
[color=blue]
> But when 'mySubDir' becomes 'my Sub Dir' myapp
> requires quotes:
> myapp.exe -P "d:\mydir\my Sub Dir"[/color]

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.
[color=blue]
> 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[/color]

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
  #5  
Old July 17th, 2005, 11:27 AM
jzgoogle@rogers.com
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php



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

  #6  
Old July 17th, 2005, 11:27 AM
John Dunlop
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php

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:
[color=blue]
> If there is a better way to invoke my app I would be more than
> happy to hear it.[/color]

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
  #7  
Old July 17th, 2005, 11:27 AM
jzgoogle@rogers.com
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php

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>";

  #8  
Old July 17th, 2005, 11:27 AM
jzgoogle@rogers.com
Guest
 
Posts: n/a
Default Re: javascript:LaunchApp and php

This if funny. My browser doesn't display the solution properly.
So here we go:

jzgoogle@rogers.com wrote:[color=blue]
> 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>";[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.