I am trying to link to a file that has the ‘#’ character in via a window.open() call. The file does exist and can be linked to just fine using a normal anchor tag.
I have tried escaping the ‘#’ character with ‘%23’ but when the window.open(myurl) gets processed, the ‘%23’ becomes ‘%2523’. This tells me that my url string is being escapped by the window.open call changing the ‘%’ to the ‘%25’.
Are there ways to work around this extra escaping.
Sample code:
<script language='javascript'> function escapePound(url) { // original attempt newUrl = url.replace('#', '%23'); // first answer attempt - doesn't work // newUrl = url.replace('#', '\\#'); return newUrl; } </script> <a href='#top' onclick='url = '\\\\MyUNCPath\\PropertyRushRefi-Add#1-ABCDEF.RTF'; window.open(escapePound(url)); return true;'>Some Doc</a>
URL that yells says ‘file://MyUNCPath/PropertyRushRefi-Add%25231-ABCDEF.RTF’ cannot be found
You seek the dark magicks of encodeURI: