waygood
asked on
javscript passing url as a parameter gets decoded
Hi people,
I've come across a strange little problem when passing a url into a function which then uses it to change the url of an iframe. For some reason it gets decoded enroute but I don't know why?
basically heres my code:-
<script>
function popup_file(url)
{
alert(url);
document.getElementById('f ileIF').sr c=url;
// other stuff
}
</script>
<a href="javascript:popup_fil e('downloa d.php?file =F5J%23%23 +02+Cleane r.pdf')" >open</a>
When it hits the alert it displays a decoded url (which may just be the alert) BUT when i look at the parameters passed to download.php it says file=F5J
%23 is #
when creating the link in php, I urlencode the filename. But the only way to pass it correctly is to urlencode(urlencode($filen ame)) but why has popupfile decoded my url in the first place????
I've come across a strange little problem when passing a url into a function which then uses it to change the url of an iframe. For some reason it gets decoded enroute but I don't know why?
basically heres my code:-
<script>
function popup_file(url)
{
alert(url);
document.getElementById('f
// other stuff
}
</script>
<a href="javascript:popup_fil
When it hits the alert it displays a decoded url (which may just be the alert) BUT when i look at the parameters passed to download.php it says file=F5J
%23 is #
when creating the link in php, I urlencode the filename. But the only way to pass it correctly is to urlencode(urlencode($filen
ASKER
I've tried that and it escapes the whole url including the script and not just the file parameter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window