Rodrigo Tassinari wrote:
> Thanks Siegfrid, this does seem to work well.
>
> The problem (which I failed to mention in the first post) is that I
> need to receive the parameters from a bookmarlet with javascript code
> from the user's browser, like:
>
> javascript:location.href='http://mysite/controller/action/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)
>
> So i need to use default javascript functions to acomplish this...
>
> Any ideas?
> Rodrigo.
Maybe use BASE 64 encoding/decoding. So following on Siegfrid's code,
change it to:
function show($url)
{
$url = base64_encode($url);
// debug($url);
$this->set('data', $this->Address->findAll($url));
}
So you remove __hex2asc() and instead use PHP's standard base64_encode.
Then, where you get the URL as a parameter use base64_decode() to get
the string back into human form.
Now, on the JavaScript, instead of doing:
javascript:location.href='http://mysite/controller/action/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)
You need to wrap location.href with a base 64 encoding function. On
hotscripts you can find a JS function to do base64 encoding/decoding:
http://www.hotscripts.com/Detailed/61788.html
You'll see that in order to use that function you have to include the
file webtoolkit.base64.js. Now, since I'm assuming you intend to
execute your JS code from a browser Link / Button, most probably best
way is to create a new SCRIPT element, specifying the source, or just
include the function's body right before your code. After doing that,
your line woud look like:
javascript:location.href='http://mysite/controller/action/'+encodeURIComponent(Base64.encode(location.href))+'/'+encodeURIComponent(document.title)
Here's the source code of webtoolkit.base64.js:
http://www.webtoolkit.info/javascript/utils/base64-decode-encode/source/index.html
Hope it helps.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---