How to make Firefox treat forward and back slashes

2019-08-18 04:24发布

Is there a way to make Firefox treat / like \ and vice versa in the url or local file path (rewrite it)? Through a tweak, add-on, or anything?

  • this is related to some local pages and links in some files.

P.S. That behavior is already in IE and Chrome.

标签: url firefox
2条回答
劳资没心,怎么记你
2楼-- · 2019-08-18 04:55

Actually you should NEVER user backslashes in a URL. Backslahes are not url safe - and although most browsers are somewhat relaxed with them, it can cause problems at many points of the url interpretation.

To ensure you don't have to do that, Windows browsers should be able to understand forward slashes in this context.

Like:

file:///C|/W95/Calc.exe

I heard there is an Addon calles Slashy that may do what you want. I have not tried it, just threw it into Google.

查看更多
我命由我不由天
3楼-- · 2019-08-18 05:00

here's something that might help you:

<html>
<head>
<script language="javascript">
    function onload() {
        var list=document.getElementsByTagName("A");
        for(i = 0; i < list.length; i++)
        {
            if (list[i].href != null && list[i].href.length > 2 && list[i].href.substring(2,1) == ":") {
                list[i].href = "file:///"+list[i].href.replace(/\\/g, '\/');
            }
        }   
    }
</script>
</head>
<body onload="onload();">
    <a href="D:\Perso\gwt/eclipse"> hey you </a>
</body>
</html>

Tested on IE, Chrome, Safari and FF

查看更多
登录 后发表回答